Hello everyone!
I'm developing a script that should change the value of the Price Level field in the Items sublist when the customer field is changed in Sales Order.
(See Script_SetPriceLevel.txt)
What needs to be done: In many Sales Orders, in the Items sublist, there are items with values set for Price Level = "2023 Price List". When someone changes the customer, it is necessary to save these values in the fields and prevent NetSuite from changing them to other values.
As I noticed, NetSuite automatically runs a function that changes several fields, including the Price Level, based on the selected customer. As you know, for each customer, you can choose a default Price Level that will be set for all items in the list.
I've prepared a script. In the validateField function, when the customer field is changed, I save the lines where the Price Level is "2023 Price List" to a variable. Then the fieldChanged function is triggered, and ideally, it should set the necessary values for certain fields based on the itemsWithPriceTwo variable, which I formed in the validateField function.
However, in the end, nothing is assigned, and my changes are not applied. Perhaps this is due to the automatic update that runs in parallel with my function, which is triggered when the Customer is changed.
Is there any way to update this field in such a way, or will the function triggered by NetSuite always take precedence over my function?