trigger remove

Location for ProcScript that marks an occurrence for deletion.

Declaration: trigger remove
Applies to: Entity
Activation: Activated by the structure editor function ^REM_OCC.
Default behavior: None, and returns 0 in $status.
Behavior upon completion: If $status is less than zero, the occurrence is not marked for deletion.

Description

This trigger is used to define the processing that should occur when the user tries to remove an occurrence. It can be used to verify that removing this occurrence is a valid action.

Note:  The data is not actually deleted from the database by ^REM_OCC. This occurs only when the data is stored. At that point, the delete trigger is activated (instead of the write trigger) for each removed occurrence .

The status of the occurrence (removed or not removed) can be checked in the delete trigger with the $occdel function.

You may want users to confirm that they actually want to remove the occurrence. This can be quite tiresome for users after a while, so it can be a good idea to create an expertise-based system, in which a global variable defines a user's abilities, such as novice or experienced. This is shown in the following ProcScript:

trigger remove
  if ($$USER_CLASS = "Novice") ;novice user, prompt for confirmation
     askmess "Mark this occurrence for removal (y/n) ? "
     if ($status = 0) ;No
       return -1 ;do not remoove
     else ;Yes
       return 0 ;mark for removal
     endif
  else ;experienced user, trust ’em
     return 0
  endif
end; remove

Related Topics