https://www.slab.org.uk/faqs/when-is-it-possible-to-use-a-duty-solicitor/
In some circumstances you can use the duty solicitor. You can use the duty solicitor if you are in custody, or if you have been released but promised to appear in court later.
A duty solicitor is available at every sheriff and JP court in Scotland, and can represent you at your first appearance in court and sometimes for the rest of the case. You won’t have to pay for using the duty solicitor.
If you are not in custody and are cited to appear in court, you cannot use the duty solicitor and would have to use your own solicitor.