netsuite The User Event Script


Closely related to the Client Script is the User Event Script. The events of this Script type are again fired when a record is being loaded or saved, but it instead runs on the server side. As such, it cannot be used to respond immediately to field changes, but it also is not limited to only users interacting with the record on a form.

User Event scripts will execute no matter where the load or submit request is coming from, whether it's a user working in the UI, a third-party integration, or another internal Script making the request.

Whenever a process or user attempts to read a record out of the database, the User Event's beforeLoad event is triggered. We can use this to pre-process data, set default values, or manipulate the UI form before the user sees it.

Once a process or user attempts to submit a record to the database, whether it's the creation of a new record, editing of an existing record, or the deletion of a record, the following sequence occurs:

  1. First, before the request actually makes its way to the database, a beforeSubmit event fires. We can use this event, for example, to clean up the record before it gets in the database.
  2. The request is sent to the database, and the record is created/modified/deleted accordingly.
  3. After the database processing is complete, an afterSubmit event fires. We can use this event, for example, to send out email notifications of changes, or to sync up with integrated third-party systems.

You can also watch this series of videos that help to visualize the events of this script type.