Trigger Clause

Event triggers provide a way to customize behavior through Program objects. Triggers can contain up to three programs (a check, an override, and an action program) which can all work together, or each work alone.

The Trigger clause specifies the program name, which event causes the trigger to execute, and which type of trigger program it is. Types support triggers for many events.

For example, when a relationship is instantiated (created), a trigger could check that an attribute value is equal to a certain value, and notification of the connection could be sent to an appropriate user. In fact, if the attribute value did not meet a specified set of criteria, a different event could replace the original. These transactions are written into program objects which are then called by the trigger.

The format of the Trigger clause is:

trigger EVENT_TYPE TRIGGER_TYPE PROG_NAME [input ARG_STRING]
  • EVENT_TYPE is any of the valid events for Relationships:
    addinterface addownership create
    delete freeze modify
    modifyattribute modifyfrom modifyto
    removeinterface removeownership thaw
    transaction
    The modify EVENT_TYPE only supports action triggers.
  • TRIGGER_TYPE is check, override, action, or precommit.
  • PROG_NAME is the name of the Program object that will execute when the event occurs.
  • ARG_STRING is a string of arguments to be passed into the program. When you pass arguments into the program they are referenced by variables within the program. Variables 0, 1, 2… and so on are reserved by the system for passing in arguments. Environment variable “0” always holds the program name and is set automatically by the system.
  • The precreate trigger allows customization before instance object creation. The precreate trigger can be configured only with the event type create.

For example:

add relationship “Assembly Relationship”
   description “Identifies the component objects used in an assembly object”
   attribute Quantity
   attribute Units
   attribute “Installation Cost”
   from
     type Assembly
   to
     type Component
   trigger create check "Quantity Check"
   trigger create override "Use Alternate Relationship"
   trigger create action "Notify John";

The modifyfrom and modifyto events provide customization hooks for the following scenarios:

  • When objects are cloned or revised, connections are created or modified based on the revision or clone rules of either float or replicate (as set in the relationship definition).
  • When the modify connection command is used to replace 1 object with another on either end.