Expression trigger example

<< Click to Display Table of Contents >>

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

Expression trigger example

Overview

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.

 

Example

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:

 

triggers1

 

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

 

triggers2

 

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.

 

triggers3

 

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

 

triggers4

 

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.

 

triggers5

 

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.

 

triggers6

 

Once created, select Ok to save your changes.

 

triggers7

 

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

 

triggers8

 

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

 

triggers9

 

 

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.