Trigger conditions are used to determine if the trigger actions should be executed after a specific event (objective) occurs. Sitecore Content Hub offers a very rich User Interface to create and combine conditions.
In the Trigger framework, conditions are organized by entity definition. For each entity definition, conditions can be combined using logical operators (AND and OR).
Trigger conditions are defined by the following parameters:
Entity definitions : Entity definitions indicate which entities to observe when the specified event occurs. Users can select multiple entity definitions with different conditions for each.
Logical operators : The logical operators indicate how to combine the conditions. The AND operator means all the conditions linked by that operator need to be met. The OR operator means any one of the conditions linked by that operator need to be met.
Conditional statements : The conditional statements are the unitary elements of the trigger conditions. Each statement is composed of a property (depending on the selected entity definition) and a conditional clause (depending on the selected property).
Creating conditions using the Sitecore Content Hub User Interface is very intuitive. Conditions can be combined and grouped in many possible ways.
The following image provides an example of a trigger's conditions set, where the entity definition is M.Asset, and where the conditional statements are grouped in various ways.
The following section explains how to configure condition through the User Interface.
Select an entity definition
To select an entity definition, click on the Add definition button under the Conditions tab.
The Any definition option in the entity definition options list means the trigger observes all the entities when the specified event occurs.
Once an entity definition is selected, users can add the conditions related to the entity definition.
Users can add multiple entity definitions by clicking on the Add definition button
Add a new condition
Users can add conditions after they have selected an entity definition. To add a new condition, simply click on the Add condition button.
Users can add multiple conditions to the entity definition by clicking on the Add condition button.
Configure the conditional statement
Select a property from the property options list.
The property options list depend on the selected entity definition.
Select a property value from the options list.
The property value options list depend on the selected property (e.g. the previous value before the change, the current value after the change).
Select the condition's operation from the options list.
The operation options list depend on the selected property and the selected property value (e.g. contains, starts with, is empty).
Some operations require additional text input in the provided text field.
Select whether the condition's operation should be case matching (for uppercase and lowercase characters) by checking the Match case checkbox.
This option is only applicable to certain properties and operations.
Select logical operator
Select the logical operator from the options list between the conditions.
The available logical operators are AND and OR, which can be combined in various ways to achieve more complex logical operators.
Logical operators combine the different conditions in the same grouping level. Sub-groups can be used to create more complex combinations.
Create a conditions sub-group
To create a conditions sub-group, click on the + button inside the condition statement's container.
Clicking on the + sign creates a new sub-group containing the selected condition with a new condition.
Each sub-group has its own logical operator.
Sub-groups can contain other sub-groups.
To select the advanced editing mode, click on the Advanced mode button.
In advanced mode, users can view the conditions in Json format. Users can also create, edit and delete conditions in this mode.
Clicking on the Basic mode button switches the view to the regular editing mode.
Select operator between entity definitions
Users can select a global operator between the different entity definitions and their respective conditions by choosing a value from the options list.
The possible global operators are :
- All: Match all of the conditions
- Any: Match any of the conditions
In Sitecore Content Hub, if a relation between two entities is modified, the change event is only produced for the changed entity's side. In other words, if a trigger condition is set to observe an entity's relation, it's only triggered if the relation is updated from the referenced entity's side. This is important when configuring a trigger condition, as explained in the following example.
For example, we want to configure a trigger that fires each time an asset is removed from a collection. The trigger condition is set to observe the 'Asset' entity definition, precisely the 'CollectionToAsset' relation. In this case, if the asset is removed (from the collection) from the asset's side, the trigger will fire. However, if the asset is removed from the collection's side, the trigger will not fire.
For a trigger to fire when an asset is removed from a collection regardless of the source of change, the trigger condition needs to include both the Asset entity definition and the Collection entity definition, each specifying the 'CollectionToAsset' relation.
For a trigger to fire when a relation is updated, the trigger condition needs to observe both entity sides of that relation.