Creating Declare Trigger rules

Define correlations between events in your case types by creating Declare Trigger rules. Declare Trigger rules run activities as a response to a specified event in a case. As a result, you provide flexible applications that precisely meet your business needs. For example, you can define a Declare Trigger rule that sends an email to a customer service representative (CSR) after a customer changes a postal address in a case.
Declare Trigger rules invoke activities when your application creates, updates, or deletes a class in the database. Operations on classes are related to actions in a case, such as saving a case or updating information in a case. You can also use Declare Trigger rules to track property changes, and for auditing purposes.
  1. In the header of Dev Studio, click Create > Decision > Declare Trigger.
  2. In the Label field, provide a descriptive name for the rule that you want to create.
  3. In the Context section, specify where your application stores the rule:
    1. From the list of application layers, select an application to store the rule.
    2. In the Apply to field, enter the class to which the rule applies.
      At run time, the system monitors property values in this class and classes that inherit from this class.
    3. In the Add to ruleset list, select a ruleset and a ruleset version in which to store the rule.
  4. Click Create and open.
    Result: The rule form opens.
  5. On the Triggers tab, in the Trigger when an instance is list, select a type of event to trigger the rule:
    Choices Actions
    Run the rule when an application deletes an instance in the specified class Select Deleted.
    Run the rule when an application saves an instance of the specified class Select Saved.
    Run the rule when a Commit method occurs for a saved instance of the specified class Select Committed Save.
    Run the rule when a Commit method occurs for a deleted instance of the specified class Select Committed Delete.
    Run the rule when an application saves an instance of the specified class and specified property values in the class change
    1. Select Saved and.
    2. In the One of these properties was modified section, in the Property field, enter a property that you want your application to track.
      For example: To track changes of the postal address, enter Data-Party.pyPostalAddress.
    3. Optional: To retain the initial value of the property that changes, in the Copy Value To (optional) field, enter a property that stores the initial value.
      Retaining the initial values is useful for auditing purposes and makes the previous property value available to the second and subsequent runs of the rule.

      Copying occurs only if the trigger activity runs, and after the trigger activity completes.

    4. To track changes to more properties, click Add a row, and then repeat steps 5.b and 5.c.
  6. To run the rule only when a case meets specified conditions, in the Condition section, in the When field, enter a When condition rule.
    The system evaluates the conditions at run time and runs the Declare Trigger rule only when the When condition evaluates to true.
  7. In the Trigger activity section, in the Name field, enter the activity that the rule invokes.
  8. In the Execute list, determine how the activity runs:
    • To run the activity during forward chaining, before the commit completes, select Immediately.
    • To run the activity in a new requestor, outside of the context of forward chaining, select In Background On Copy.
      Note: Ensure that the activity that you select to run in the background includes the Commit method.
    When you select an activity of a different type than Trigger, ensure that the preconditions and transitions in the activity do not use When condition rules and do not call functions. For more information about activities, see Creating an activity.
    CAUTION:
    Although your application can contain multiple Trigger activities for the one class that is specified in the Apply to field, you cannot control the order in which two or more triggered activities run. Create activities that provide correct results when running in any order, and when running either independently or simultaneously.
  9. Click Save.