The Shiptheory SuiteApp comes bundled with several scripts, the most important of which is the user event script which gets deployed on the item fulfillment record. It can be helpful to understand how this script works and how it operates on the item fulfillment, especially of you want to write you own custom scripts which also operate on the item fulfillment. The sections below highlight the events which the script runs on and how each event is handled.


beforeSubmit

The beforeSubmit event runs before the item fulfillment is submitted and before any data is committed to NetSuite's databases. Shiptheory's script does the following:

  1. Check the event type is one which is supported (Created, Edited, Packed or Shipped)
  2. Loads settings
  3. Checks that the status of the item fulfillment is the status which is set as the trigger status in the settings
  4. Gets the user who triggered the event
  5. Stores the ID of the user in the custbody_shiptheory_print_user_id custom field to be used in Shiptheory's print per user functionality


afterSubmit

The afterSubmit event runs after the item fulfillment's data has been committed to NetSuite's database. Shiptheory's script does the following: 

  1. Check the event type is one which is supported (Created, Edited, Packed or Shipped)
  2. Loads settings
  3. Checks that the status of the item fulfillment is the status which is set as the trigger status in the settings
  4. Checks that the item fulfillment hasn't already been pushed to Shiptheory
  5. Pushes the item fulfillment to Shiptheory's queue
  6. Marks the item fulfillment as pushed by setting the custbody_sent_to_shiptheory custom field to true.


It is recommended that you run Shiptheory's user event script last so that Shiptheory fetches the correct data from NetSuite. To learn more about changing the execution order of user event scripts you can read our guide.