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:

  1. Read the fields to use in the query. For example, the Due and Planned Start Time fields.
  2. Give both fields a name to use in the conditional query.
  3. Enter the conditional query that checks whether the Due field is greater than the Planned Start Time.
    1. If it is, then allow the record to be saved.
    2. If it is not, then display a message, and do not allow the record to be saved.