How User Event Scripts are Executed

Important:

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.

Tip:

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:

User event execution flow on beforeLoad event between client and server.
  1. 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).

  2. The application server checks permissions.

  3. The database loads the info into the application server for processing. The beforeLoad operation happens here—before the data goes back to the client.

  4. The client gets the validated and processed beforeLoad data.

Note:

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:

User event execution flow on beforeSubmit and afterSubmit events between client and server.
  1. 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:

    1. checks permissions

    2. processes the data and runs validation checks during beforeSubmit

    At this point, the data hasn’t been saved to the database yet.

  2. After validation, the data gets saved to the database.

  3. 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:

    1. sending email notifications about the new data

    2. creating child records based on the new data

    3. assigning tasks to employees using the saved data

Note:

Asynchronous afterSubmit user events only work during webstore checkout.

Related Topics

General Notices