The onSave and onPreSave Functions in JavaScript Code
The onSave function is called whenever a user saves a new or modified record by selecting the Save button. You can use the onSave function to perform several actions, including the following:
- To automatically complete fields according to the values stored in existing fields, including hidden and read-only fields.
- To save a field value, overwriting any user-entered values.
- To perform data validation to check that conditions are met (such as verifying that end time greater than start time).
- To perform data validation to ensure that fields are completed according to the values in a parent module.
- To automatically open an object for creation after the current record is saved.
- Two actions are available when the Save button is selected, and you enter both actions into the onSave code. The actions, which you can combine within the same piece of code, are as follows:
- onPreSave. Performs data validation, and either allows records to be saved or prevents records from being saved. For more information, see "JavaScript onPreSave Functions".
- onSave. Sets the values or triggers another record to be created.Â
Â