Why you might need to change the order in which user event scripts run
Before we understand how to order user event scripts in NetSuite we should first understand why the order in which user event scripts run is important.
Shiptheory's SuiteApp sends shipments to Shiptheory's queue via a user event script on the Item Fulfillment record. When Shiptheory receives a notification the shipment data is fetched from NetSuite. It does not wait for other scripts to finish updating the Item Fulfillment and this can create a race condition.
"A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence to be done correctly." - techtarget.com.
To better understand race conditions let's look at an example. In our example we have 2 scripts running. We'll let the first script be Shiptheory's user event script and the second script be a simple script which fetches package information from an external service and then updates the Item Fulfillment with the correct package count. If Shiptheory's script runs first then Shiptheory might start downloading the Item Fulfillment with incorrect package information as our second script has not yet finished running. The shipment in Shiptheory is then created with an incorrect package count and the wrong number of labels are created and printed.
How to change the order of user event scripts
In NetSuite go to Customization > Scripting > Scripted Records
Find the record type which the scripts you want to modify run on. In the case of Shiptheory this will be the Item Fulfillment record. When you find the relevant record type click "Edit".
On this page you will see a list of user event scripts. You can use the 6 dot symbol on the left hand side of the table to drag and re-order the execution order of the scripts. Ideally, you want Shiptheory's script to run last after all changes have been made to your Item Fulfillment.