trigger validate (Entity)

System trigger for validating entity occurrences.

Declaration: trigger validate
Applies to: Entity
Activation: Activated during explicit or validation:
  • Explicitly, during the processing of one of the validation statements (validate or validateocc).
  • Implicitly, during the processing of a store statement.
  • Implicitly, after declarative checks and, in forms, before the leaveModified trigger is activated.
Default behavior: If no ProcScript is present in this trigger, there is no action; both $status, $occvalidation, and $occcheck are set to 0.
Behavior upon completion: If $status is less than zero, validation is considered to have failed and the entity-level error trigger is activated.

Description

The validate trigger defines the procedural checks that are done to validate a modified occurrence.

Validation is performed only if the occurrence is marked as modified ($occmod is 1) and still requires validation ($occvalidation is 1), or if $occcheck is 1.

Because the validation statements (validatefield, validatekey, validateocc, and validate) activate the validation triggers (validate and validateKey), these statements should be used with caution within the validation triggers.

Validate Occurrence

In the following example, the fields CITY and ZIP_CODE are cross-checked with each other before the occurrence is considered valid:

trigger validate ; of Entity
  if ( CITY = "" & ZIP_CODE = "") ;city & zip are missing
     $status = -1 ;oops!
  elseif ( CITY = "" & ZIP_CODE !="") ;city is blank, but zip is present
     activate "LOCATOR".FILL_CITY_FROM_ZIP(CITY, ZIP_CODE)
  elseif ( CITY != "" & ZIP_CODE = "") ;city is present, but zip isn't
     $status = -2 ;can't help here
  else ;both city and zip are present
     activate "LOCATOR".MATCH_CITY_ZIP(CITY, ZIP_CODE)
  endif
return ($status) ;return what we've got
end; validate

Related Topics