Defining a Query in the onPreSave Function
The following procedure shows you how to define a query in onPreSave, which involves defining what you want to query or check, and what you want to happen as a result of running the query.
To define a query in the onPreSave function:
- Read the fields to use in the query. For example, the Due and Planned Start Time fields.
- Give both fields a name to use in the conditional query.
- Enter the conditional query that checks whether the Due field is greater than the Planned Start Time.
- If it is, then allow the record to be saved.
- If it is not, then display a message, and do not allow the record to be saved.