Setting Script Execution Event Type from the UI

In the Event Type field on the Script Deployment page, you can select a single event type that you want to trigger the execution of the script (see following figure). If the Event Type field is left blank, the script will execute only on the events specified in the .js script file.

The Script Deployment page setting the Event Type to Edit.
Note:

The Event Type field is available on Script Deployment pages for Suitelet, user event, and record-level client scripts only.

The Event Type field is useful if you want to specify a script execution context at the time of script deployment, without having to modify your .js script file. After you select an event type and click Save, the deployed script will execute only on that event, regardless of the event types specified in the .js script file.

Be aware that event types selected on the Script Deployment page take precedence over the event types specified in the .js script file. For example, if the create event type is specified in the script, selecting Edit from the Event Type field on the Script Deployment page will restrict the script from running on any event other than Edit.

The following snippet is from a user event script. Notice that the event type specified in the code is create (context.UserEvent.CREATE). If the Edit event type is specified on the Script Deployment page, the script will execute only when the specified record is edited, not created.

          function followUpCallAfterSubmit(type) { // execute the logic in this script onlyif a new customer is created if (context.type !== context.UserEventType.CREATE) return; // obtain a handle to the newly created customer record var customerRecord = context.newRecord; // remainder of script...... }
} 

        

Related Topics

General Notices