Adding customer contact on sales order

Hi, I have added a custom field called “customer contact” in the sales order form. I want this field to have options of all the contacts linked to the customer selected which are stored in the CRM > Contact. how do I achieve this ?

Hi @Akshay_Chordia,

That for, Please apply the client script.

frappe.ui.form.on("Sales Order", {
    refresh: function(frm) {
        frm.set_query("customer_contact", function() {
            return {
                filters: [
                    ["Dynamic Link","link_doctype", "=", "Customer"],
                    ["Dynamic Link","link_name", "=", frm.doc.customer]

Then reload and check it.

Thank You!

Hi, Thanks a lot for replying. But where do I add this script

Hi @Akshay_Chordia,

Please go to the Client Script Doctype and then add it.

Please check it.

Thank You!

1 Like

Thanks a lot for your help