Expression trigger example

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Experience design > Advanced topics > Triggers >

Expression trigger example


Triggers are automatic actions that react to any change in data and run immediately after that, when a condition is met, to activate a process or execute an expression.

The following section illustrates an example regarding a trigger that executes an expression.


For more information about this feature refer to Triggers.



Triggers will be executed over the changes that are done through Bizagi's regular use (e.g. via expressions such as setXpath or through the Work Portal).

Triggers will NOT execute changes done directly over the database.

Triggers will execute on virtualized entities when changes over the data are done through Bizagi's regular use (e.g. via expressions such as setXpath or through the Work Portal). However, triggers will NOT be executed when changes happen externally on the source table are then Bizagi is updated via virtualization.



Consider a scenario in a retail store where a registered Customer becomes VIP if he/she has a purchase of at least 1,000 USD. For this example, the following data model has been defined:




When the Purchase process is started, a Customer will have a list of purchased products .




To create the trigger that sets the customer as VIP, go to the entity to be evaluated, in this case the Purchase entity.

Expand it and right-click the Triggers node, then select New trigger.




In the configuration window set a display name and a condition to determine when the trigger will be evaluated to be launched.




Select or create the condition rule. This condition will be the one that determines if the trigger is executed or not.

In this case we want the trigger to be executed when the total value of a purchase is 1,000 USD or greater. As a good practice, we manage the value as a vocabulary definition.




Once the condition has been set, define the expression to execute. In this case we want an expression that sets the customer as VIP.

Select Execute an expression and then click the plus button to create a new expression. In this expression set the customer attribute called VIP as true.




Once created, select OK to save your changes.




Now you can see the trigger listed in the Triggers node.




Whenever a purchase exceeds the value specified, the trigger will set the Customer as VIP.




Data mapping

When the trigger launches an expression, the expression defined is executed on the record that triggered. That is, the record is the context of the expression.

Thus, the record that triggered the expression and all its information can be used in the expression.

In the example above we would have all the Customer's information available, as well as the products. Everything that can be navigated through XPath from the Purchase record, can be obtained.