Sales Order – Suitescript to get attached contacts of salesorder
I have attached 3 contacts to a Sales Order from UI. There is Contacts sub list under Relationships tab. I have selected contact from Contact List, attached the contact with sales order by clicking Attach button. I want to retrieve the first name, last name phone of the first contact of the sales order using suitescript.
Any help would be appreciated.
I know that it has been answered in the Slack channel, but it’s better to have the solution here as well.
We need to create a “Contact” saved search joined with Transaction, like that:
And to use it in the script:
const savedSearch = search.load({id: <savedSearchId>}); savedSearch.filters.push(search.createFilter({name: 'internalid', operator: search.Operator.ANYOF, values: <salesOrderId>, join: 'transaction'}));