The fireSlavingSync function in a NetSuite client script is used to trigger the re-calculation of dependent fields when a field changes. This is particularly useful in ensuring that any fields that are dependent on the value of another field are updated immediately when that field’s value is changed.
By default fireSlavingSync is set to false. By slaving it means that “other fields (child fields) are changing its value based on what you set on that parent field”. One great example is the ‘Item’ field on the ‘item’ sublist. When you set the ‘item’ field, other fields are sourcing its value from it. (e.g. description, rate, quantity, etc). If your script is trying to set this field, it is recommended to set the fireSlavingSync to true so that it will finish sourcing the child fields first before continuing with the rest of your script.
Here is a basic overview of how to use fireSlavingSync in a NetSuite client script:
Usage in Client Script
- Create the Client Script: Define a client script that includes the
fieldChangedfunction. - Use
fireSlavingSync: CallfireSlavingSyncwithin thefieldChangedfunction to ensure dependent fields are updated.