Events
Scripts are triggered by events. The required Event is specified in the Scripting Studio Tools and Settings options.
![User event selection for form scripts in the Scripting Studio tools and settings pane.](img/UserScripting/FormEventOptions.png)
You should select the Event according to the purpose of the Entrance Function, see the diagram below.
![User event sequence and descriptions of typical use cases for scripts associated with each user event.](img/UserScripting/FormEvents.png)
Only forms that can take part in an approval process receive approval events.
-
On submit — Always executed. This is the first event that occurs when the user click SAVE.
-
Before save — Always executed. This is where you should check that any special conditions on the form are valid and raise form errors if required by calling NSOA.form.error(field, message).
Note:The record does not exist in the database at this stage so you can’t call wsapi functions to change any of the record values.
-
After save — Executed if no form errors are raised. This is where you should call wsapi functions to modify the data held on this or related records.
-
Before approval — This is where you can perform additional checks and prevent a record from being sent for approval by calling NSOA.form.error(field, message).
-
After approval — This is where you can perform additional actions following a record approval or reject.
The OpenAir mobile app does not support “On submit,” “Before save,” or “After save” scripts associated with the timesheet entity form.
OpenAir Mobile 4.0 or later version supports:
-
All form scripts associated with the expense report and receipt entity forms.
-
"Before approval" and "After approval" scripts associated with the timesheet entity form.
For an example of script that is executed both in OpenAir and OpenAir Mobile, see Ensure resource time entry matches booking planning and project worked hours
Form scripts may be triggered by an event associated with user interaction — when a user clicks Save, for example.
Form scripts can also be triggered by an event associated with a process utilizing the form software logic — when importing project records from NetSuite using OpenAir NetSuite Connector, for example, depending on the integration configuration. For more information, see Scripting and NetSuite Integration.