trigger leaveModified
Trigger that handles processing after the user moves to another occurrence in a form, after having modified the original occurrence.
Declaration: | trigger leaveModified
|
Applies to: | Entity in Form component |
Activation: | Activated when the user repositions the cursor to another occurrence after modifying the original occurrence, and by set $occcheck. For details, see Trigger Activation. |
Default behavior: | If no ProcScript is present in this trigger, there is no action. |
Behavior upon completion: | If $status is less than zero, the user cannot leave the occurrence; the terminal will not beep. (Remember that a negative value during a ^STORE immediately terminates the ^STORE function.) |
Description
This trigger is the main location for all occurrence-level calculations, such as updating a running total.
Trigger Activation
The leaveModified trigger is activated (after the entity-level validate trigger) when the user repositions the cursor to another occurrence (either of the same entity or of another entity) after modifying the original occurrence. This cursor movement can result from structure editor functions such as ^NEXT_OCC, ^STORE, ^ACCEPT (but not ^QUIT), or ^CURSOR_DOWN.
The leaveModified trigger is not activated in the following situations:
- If the only modifications were made by ProcScript statements.
- If the cursor returns to the occurrence and leaves again, and the user does not remodify the data during the new visit.
It is possible to force this trigger to be activated using the ProcScript statement set$occcheck.
If you place ProcScript in the leaveModified trigger, it is wise (at least during application development) to use set $occcheck in each ProcScript module that modifies fields in this entity. This ensures that the code you supply in the entity-level leaveModified trigger is always activated whenever the data in the occurrence is modified.
leaveModified
The following example prevents the user from leaving the modified occurrence if the field SALARY is greater than 100000 and the field JOB is not PRESIDENT:
trigger leaveModified if ((SALARY > 100000) & (JOB != "PRESIDENT")) message "See me at once! -- The Boss" return -1 endif end; leaveModified