It is not uncommon for a judge to order a UA when a defendant comes to court. There are some nice legal arguments that he must have at least reasonable articulable suspicion in order to make this order, but I have often seen judges order them as a matter of course. You can object and theoretically appeal, but you might be doing so from a jail cell. Generally speaking, depending on the jurisdiction, an attorney can appear for you on a misdemeanor. This would reduce the chances of a UA being ordered. Eventually the defendant will have to show up in court though and a UA could be ordered at that time. Certainly if the defendant is convicted he will be ordered to go through treatment and take UA's. Given that Possession of Marijuana is a Class A misdemeanor and punishable by up to one year in jail your son should be speaking with an experienced drug defense lawyer as soon as possible.
Legal disclaimer: Legal disclaimer: Patrick M. Lewis, (913) 558-3961, firstname.lastname@example.org. This answer is intended to provide general information about the justice system. It does not provide legal advice nor does it create an attorney-client relationship. It does not provide the basis for making decisions about a course of action. Legal advice requires more communication and information than is possible in this format. Many important considerations and factors need to be investigated and discussed before an attorney could give legal advice about this issue. Before making any decisions about a course of action readers are strongly encouraged to contact a lawyer and secure an attorney-client relationship. Readers must also understand that this format does not provide for confidential communication.