How User Event Scripts are Executed
User event scripts can’t be triggered by other user event scripts or workflows with a Context of User Event Script—so you can’t chain them. But you can run a user event script from scheduled scripts, portlet scripts, or Suitelets.
User event scripts run during beforeLoad, beforeSubmit, and afterSubmit events.
You can choose the order your user event scripts run on the Scripted Records page. See The Scripted Records Page.
beforeLoad
The following diagram shows an overview of what occurs during a beforeLoad operation:

-
The client sends a request to read record data. This can come from the UI, SOAP and REST web services, CSV import, or server SuiteScript (not other user event scripts).
-
The application server checks permissions.
-
The database loads the info into the application server for processing. The beforeLoad operation happens here—before the data goes back to the client.
-
The client gets the validated and processed beforeLoad data.
You can’t source standard records during beforeLoad. Use the pageInit client script instead. See pageInit(scriptContext).
beforeSubmit and afterSubmit
The following diagram shows an overview of what occurs on beforeSubmit and afterSubmit operations:

-
The client sends a write request to the application server—this can be from the UI, SOAP/REST web services, server SuiteScript, CSV import, or XML. The server:
-
checks permissions
-
processes the data and runs validation checks during beforeSubmit
At this point, the data hasn’t been saved to the database yet.
-
-
After validation, the data gets saved to the database.
-
When afterSubmit runs, it grabs the new data from the database and sends it to the application server for more processing. The afterSubmit actions on saved data can include:
-
sending email notifications about the new data
-
creating child records based on the new data
-
assigning tasks to employees using the saved data
-
Asynchronous afterSubmit user events only work during webstore checkout.