Dispatch Address based on Branch

Is there a way to auto select Dispatch address based on a logged in users associated branch in Sales Documents.
In this case user permission will be set for a specific branch.

Possible, but it is challenging,

If you define the branch in the address master, you can retrieve the dispatch address using certain logic with client script/server script.

1 Like

Great, It worked
Created a company address with branch name,
On load of the document set the default dispatch address name to the branch name, then the following code will take over in the client script.
frappe.ui.form.on(‘Sales Order’, ‘dispatch_address_name’, function(frm, cdt, cdn) {
return frm.call({
method: ‘erpnext.utilities.doctype.address.address.get_address_display’,
child: cdt,
args: {
‘address_dict’: frm.doc.dispatch_address_name
callback: function(r) {
frappe.model.set_value(‘dispatch_address’, r.message);