How to auto update "Sales Person" field when Customer is selected in Quotation?

Hi, I want this custom field (sales_person) to automatically fill with the first sales person in the child table “Sales Team” from the Customer doctype when a Customer is selected in a new Quotation. I assumed since it’s a table it could work like this in a custom script:

cur_frm.add_fetch(‘party_name’, ‘sales_team[0].sales_person’, ‘sales_person’)

But that just gives this error : " Wrong fieldname sales_team[0].sales_person in add_fetch configuration of custom client script"

Can someone tell me how to do this?

This should not be required, Actually when you enter the customer details in customer master, always fill the sales team details and their contribution (if joint sales between the team) and save it.

When you will create the sales invoice for that particular customer, it will automatically fetch the sales person details in Child table. You won’t have to do anything here.

Let me know if it worked as per your use case. I think I got your use case right !

See below screenshots

Thank you for the response. I realize that it autoupdates in the sales invoice, but I want it to autoupdate in a custom field in the Quotation doctype. There is no sales person field in the Quotation doctype by default. Is there a way to do this?