Jump to content

Triggers

From NusaATK
Revision as of 17:09, 15 September 2006 by bahtiar (talk | contribs)

You can use the following triggers on a node:

  • preAdd
  • postAdd
  • preUpdate
  • postUpdate
  • preDelete
  • postDelete

to perform various tasks after or before an action has been executed.

These triggers take only 1 argument, which is an array with the record.

Pre triggers

If the trigger is a pre- trigger, you can make the argument to be a pointer and you can adjust the record before it is added/updated/deleted.

Pre-trigger returning false does not necessarily halt the action being performed (because of backwards compatability). To actually halt the action, use the triggerError-function. Doing so will add an entry in the record called 'atkerror'. Upon detecting this, the action will halt. And the message in the atkerror entry will be displayed as an error. For more information on the triggerError function, please see the API documentation on the function.

Listeners

Note that triggers are superseded by Listeners, a more flexible concept as Listeners can be applied at runtime.