Based on some conditions, we can trigger some actions automatically using these
automated actions. Let's take an example of updating the cost of the product when
the status of the product changes from in use to deprecated. Open the product form
view in studio edit mode and click on the Automations button on the top as shown
in the image below.
The domain conditions must be satisfied before the update of the record. For this,
we have to click on the Edit Domain button and add filters as given below.
Under data to write select value as cost as we are going to update the field cost
in product. Template model. Give evaluation type as value and set the value 0.
Here we can see the fields Action name which is name of the automated action, model,
active Boolean button which is used to activate the action. If this Boolean value
is disabled, then the rule will be hidden and it will not be executed. Next field
is the trigger, which is a selection field. Here we have to select when the action
should be triggered. We have selected ‘on update’. Next two fields are for setting
the domains for this automated action. First one is the ‘Before update’ domain.
If this domain is set, then this condition must be satisfied before updating the
record. Next one is ‘Apply on’ domain. If we set this domain, then this condition
must be satisfied before executing the action rule. In our case, here we can see
how many records are present in that particular status. We have given action to
do as updating the record. Under the Data to write tab, we have to select the field
name, here the field cost is chosen, Evaluation type is ‘value’ and set the value
field as 0 as we have to update the price to zero while updating the status of the
product from in use to deprecated.
Let's see how it works. Go to the product form view. Here in the image below we
can see that the product status is in cost and its price is 100.
Once we change its status from in use to deprecated then the cost will be automatically
updated to 0 as shown in the image below.