Points to note when forming a validation
Copy the link to the article

Validation is designed to create additional checks for changes to orders and customers made by system users. Checks are applied not only when editing in the order/customer card, but in mass operations.

A boolean expression is specified in the condition; if true, the action will be canceled and the user will receive an error message.

In the condition, you can work with the object being acted upon (this is order or customer), as well as with the object changeSet (type Change\EntityChangeSet), which contains information about the fields to be changed.

changeSet.isUpdate() and changeSet.hasChangedField('payments.status')

In some cases, validation requires checking some attributes of the user who changes the data in the order/customer. For example, to check that the user is in a specific group. You can view the user changing the data by using the user() function.

    1. Prohibition to change the payment status of the order
changeSet.isUpdate() and changeSet.hasChangedField('payments.status')
    1. Delivery date must be today or later
order.deliveryDate < date('now 00:00:00') and (
(changeSet.isCreate() and order.deliveryDate) or
(changeSet.isUpdate() and changeSet.hasChangedField('delivery_date'))
    1. Only the user of the "Logistician" group can carry out the shipment.


By default, there is no "Logistician" group in the system, but you can create the user groups you need.

changeSet.hasChangedField('shipped') and not user().hasGroup('logist')
    1. User can change only certain fields
changeSet.hasChangesExcluding(['status', 'first_name', 'last_name'])
Thank you for your feedback.
Was this article helpful?
  • Рекомендации не помогли
  • Нет ответа на мой вопрос
  • Текст трудно понять
  • Не нравится описанный функционал
Previous article
Working with products in triggers, validations and price types
Order details are an array of data, therefore, working with them is conducted using special filters created in PipeLanguage. In this article, we will analyse how to work with filters in price types, triggers and validation and in the context of products.
Next article
Checking the executions of triggers and validation
If you need to check a trigger or validation for correct functioning, you can use the actions log, which displays each execution and, if it occurs, an error with a detailed description.