Conditions for trigger execution
Copy the link to the article
Copied

There are two ways to specify a condition for trigger execution:

  • via the visual builder, using existing blocks;
  • via the editor, using the code in the syntax (PipeLanguage).

Let's consider each in details:

Editor mode

The editor is used to specify conditions that cannot be set using the visual builder because they don’t exist or, for example, when using a complex chain of objects and nesting conditions.

The editor is also used to specify the conditions for the following events: "The customer visited the site", "The customer leaves the site" or "The customer did not visit the site". Note that Daemon Collector must be connected for these events.

Using the editor, you can make changes to the condition created using the builder.

Note

The builder is not available if:

You switched to the editor and made any change. If the change was accidental, you should exit the trigger without saving the changes.

The trigger condition was originally written in the editor.

When you delete all conditions in the trigger editor, the builder becomes available again.

Builder mode

Important

The builder mode is available for all events, except for those that are used in conjunction with Daemon Collector ("The customer visited the site", "The customer leaves the site" or "The customer didn’t visit the site"). Use the editor when you select these events as the builder mode will be disabled automatically.

The builder is used to create a trigger using predefined blocks with conditions, the list of which is formed based on the selected event.

The new condition is added from the already existing list of conditions. You can add a condition to an existing group, or add a condition to a new group at the same level. Conditions both within a group and between different groups are treated by the logical operators AND/OR. Selecting operators is available both within one group and between them.

Working with a condition (selecting, changing and setting up) is carried out in the reveal (window), which is displayed on the right side of the browser. Each condition and option has its hints that are displayed on hovering.

For convenience, a search field is available that will allow you to find the desired condition. The search is carried out by a sequence of characters entered into the search bar. To see the full set of conditions (without the applied filter), reset the entered value by clicking on the cross in the search field.

Depending on the type of the condition, the following configuration options are available:

  • Selecting a value from the list, including multi-selection
  • Checking that it is the symbolic code that contains the entered characters and not the name of the object
  • Checking a feature (its presence/absence)
  • Comparison of the initial and final values ​​when changing the field, including the "Any" option.

Important

You cannot save a condition for a trigger if it is not filled in completely.

To delete the added condition, click on the cross which is located in the right part of it. It is possible to delete only from a chain of conditions but not from the list.

If necessary, you can duplicate the conditions. In the reveal (window), in the bottom right corner, click on the "Duplicate" button, and you will immediately find yourself in the editing mode of the duplicate.

"Other field" condition

"Other field" is a condition that can refer to the system and custom fields of order/customer cards.

After selecting a section (order page or customer page), you should select the desired field.

Important moments:

  • The condition works only with fields of customer/order cards and custom fields (custom fields for an order or customer).
  • The condition works only with such fields as string\text, number, data book, flag (Yes/No).
  • Some fields may not be available for selection because they are not supported by the builder (for example, date fields or the delivery interval). With the fields that cannot be found, you should work in the editor of conditions.
  • For order triggers, you can check the value of the fields of the order and customer (that is connected with the order) and the change of the order fields. For customer triggers, you can check the value of the fields of the customer and order (the first or the last order of this customer excluding cancelled orders) and the change of the customer fields. Field changes are checked only if the section matches the selected event.
  • For call triggers, you can check the value of the customer and order fields if these entities are attached to the call.
  • Search by fields is available when they are selected.
  • In a postponed trigger, field changes are not checked.

When filling in a condition, a step-by-step builder is used, which changes the data that should be filled in depending on the selected field in the previous step.

Examples of trigger conditions:

Example 1

For example, there is a special offer: if 3 orders have been delivered by the DPD delivery, the delivery of the fourth order by this delivery service will be free of charge (for example, you can send a communication with a promo code for free delivery).

In the trigger condition, we specify that the order status has changed from any to “Completed”, while DPD is the selected delivery type in the order and the customer has 3 completed orders (which we count in the customer's custom field “Number of completed orders”).

In the editor, the condition looks like this:

(changeSet.hasChangedField("status") and changeSet.getNewValue("status").code in ['complete']) and (order.deliveryType.code in ['dpd']) and (order.customer.customField('complete_orders') == 3)

Example 2

We need to track that any changes have been made to the delivery address of the order. To do this, add address fields with tracking of the field change from any to any. Use the OR operator to check if any of the address fields have been changed.

In the editor, the condition looks like this:

((changeSet.hasChangedField("delivery_address.city")) or (changeSet.hasChangedField("delivery_address.building")) or (changeSet.hasChangedField("delivery_address.index")) or (changeSet.hasChangedField("delivery_address.housing")) or (changeSet.hasChangedField("delivery_address.metro")) or (changeSet.hasChangedField("delivery_address.flat")) or (changeSet.hasChangedField("delivery_address.block")) or (changeSet.hasChangedField("delivery_address.region")) or (changeSet.hasChangedField("delivery_address.country")) or (changeSet.hasChangedField("delivery_address.house")) or (changeSet.hasChangedField("delivery_address.street")) or (changeSet.hasChangedField("delivery_address.floor")))

Note

Use the "Duplicate" button in the condition change window so that you do not select a condition and system section each time.

Example 3

Let's say we need to notify the shipment warehouse that the order has moved to the assembling status and the warehouse needs to prepare the ordered products.

In the trigger condition, it is enough to specify that "Order status" has changed from any to "Assembling". Select the desired communication as an action.

In the editor, the condition looks like this: (changeSet.hasChangedField("status") and changeSet.getNewValue("status").code in ['assembling']) .

Editor mode

The editor is used to specify conditions that cannot be set with the visual constructor due to their absence or, for example, when using a complex chain of objects and nesting conditions.

The editor is also used to specify conditions for the events " Customer entered the site", "Customer leaves the site" or "Customer did not enter the site". Please note that Collector should be enabled for these events.

Using the editor you can make changes to the condition created with the help of the constructor.

Thank you for your feedback.
Was this article helpful?
No
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Yes
Previous article
Trigger event
Setting up a trigger starts with selecting an event - something that the trigger will respond to.
Next article
Adding an action to a trigger
Action is what the trigger will do when the previously set conditions are satisfied.
#}