It is the NetSuite server that runs user event scripts. Records can be created, loaded, updated, copied, deleted, or submitted by users, among other activities that trigger their execution. User event scripts can be used with the majority of standard NetSuite records as well as custom record types. The following are examples of exceptions: certain revenue recognition records, certain timecard-related records, and records used for personal identification. Regarding particular records, see SuiteScript Supported Records for further details.
User event scripts can be used to perform the following tasks:
1. Implement custom validation on records
2. Enforce user-defined data integrity and business rules
3. Perform user-defined permission checking and record restrictions
4. Implement real-time data synchronization
5. Define custom workflows (redirection and follow-up actions)
6. Customize forms.
SuiteScript 2.1 User Event Script Entry Points are,
1. afterSubmit(context): Executes immediately after a write operation on a record.
2. beforeLoad(context): Executes whenever a read operation occurs on a record, and prior to returning the record or page.
3. beforeSubmit(context): Executes prior to any write operation on the record.
afterSubmit
Describes the action that takes place following the submission of a record.
For carrying out any necessary activities after a write operation on a record, the afterSubmit operation is helpful. These actions can involve synchronization with an external system, email notice, browser redirection, and the creation of dependent records. The new (or updated) record in read-only mode. To edit a record, use the record.load(options) method to load the newly submitted record. Make changes and submit the record again.
The old record (previous state of the record) in read-only mode.
beforeLoad
Defines the function that is called every time a record is read, that is, before the record or page is returned, and before the record is loaded. These actions consist of loading a record, reading a record via SOAP web services, and navigating to a record in the user interface. Standard records cannot be sourced using the beforeLoad event. For this, use the pageInit client script. Refer to scriptContext.pageInit. The new record (the record being loaded).
beforeSubmit
Defines the process that runs before a record is submitted, that is, before the record is written to. After the write operation, modifications made to the current record in this script remain in effect. Validating the submitted record, completing any necessary permission and restriction checks, and making any last-minute edits to the existing record can all be done using the beforeSubmit event. The new (or updated) record. The old record (the previous state of the record).