Automation rules¶
An automation rule runs one or more actions on the records of a model when a trigger happens and the records meet your conditions. An action can update a record, create an activity or a record, send a message, add followers or run Python code.
Who |
A user with the Administrator access right of the Settings app, with the developer mode active. |
App |
Settings |
To create an automation rule, go to Settings ‣ Technical ‣ Automation ‣ Automation Rules and click New.
Note
The Technical menu is shown only when the developer mode is active, and only to users with the Administrator access right of the Settings app.
Model¶
Choose the model whose records trigger the rule, for example Sales Order.
Trigger¶
Choose when the rule runs. The triggers are grouped in the list:
Values Updated: the rule runs when a value of the record changes to the one you choose. The triggers offered depend on the fields of the model, for example:
User is set: the record is assigned to a user. You can choose a specific user, or any user.
State is set to: the state of the record changes to the state you choose, for example Done.
Tag is added: a tag you choose is added to the record.
Email Events:
On incoming message: an incoming message arrives on the record.
On outgoing message: an outgoing message is sent from the record.
Timing Conditions:
Based on date field: the rule runs relative to a date field of the record. Set the delay, its unit (minutes, hours, days or months) and whether the rule runs before or after the date. For example, send a message 15 minutes before a meeting.
After creation: the rule runs after the delay counted from the creation of the record.
After last update: the rule runs after the delay counted from the last update of the record.
Custom:
On create: the rule runs when a record is created.
On create and edit: the rule runs when a record is created or edited. In When updating, choose the fields whose change runs the rule; a change of any other field does not.
On deletion: the rule runs when a record is deleted. Since the record is being removed, only limited actions make sense.
On UI change: the rule runs every time a watched field changes in the form, whether or not the user saves. This trigger needs Python code.
External: On webhook runs the rule when an external system calls the secret URL of the rule.
Before Update Domain¶
The Before Update Domain is the condition that a record must meet before it is updated. It is shown for the triggers that react to a change of an existing record.
Click Edit Domain to write the rules.
Apply on¶
The Apply on domain is the condition that a record must meet to run the actions. You can define several rules: the record must match all of them.
Actions To Do¶
In the Actions To Do tab, click Add an action and choose what the rule does. The types are:
Update Record
Create Record
Duplicate Record
Create Activity
Send Email
Send SMS
Add Followers
Remove Followers
Execute Code
Send Webhook Notification
Multi Actions
Update Record¶
The rule updates the value of a field of the record. Choose the field and the value.
Note
To update more than one field, add one Update Record action per field.
Create Activity¶
The rule schedules a new activity on the record.
Activity Type: choose the type of activity.
Title: the title of the activity.
Due Date In: the number of days until the due date.
User Type: choose who receives the activity.
Specific User: the activity is assigned to the user chosen in Responsible.
Dynamic User (based on record): the activity is assigned to the user found in the field of the record that you name.
Note: the description of the activity.
Example: after a quotation is updated, assign a call activity to the salesperson in charge of the quotation.
Send Email¶
The rule sends a message to the people concerned by the record.
Email Template: choose an existing template.
Send Email As:
Message: the message is posted on the record and notifies all followers. It appears in the messaging history.
Email: the message is sent by email to the recipients of the template and does not appear in the messaging history.
Note: the message is posted as an internal note, visible to internal users in the messaging history.
Send SMS¶
Send SMS works like Send Email, with an SMS template. It needs an SMS service to send the messages.
Add Followers¶
The rule adds followers to the records that meet the conditions. Choose Specific Followers, or Dynamic Followers taken from a field of the record.
Remove Followers¶
The rule removes followers from the records that meet the conditions.
Create Record¶
The rule creates a new record of another model.
Record to Create: choose the model of the new record.
Name: the default name of the new record.
Link Field: choose the field that links the new record to the record that ran the rule.
Duplicate Record¶
The rule creates a copy of the record that ran it.
Execute Code¶
The rule runs a Python script. Write the code in the Code tab; the Help tab lists the variables that you can use in the script.
Block edits or deletions of an approved record¶
An automation rule that raises an error stops the operation that triggered it: the change is not saved and the user reads your message. You can use it to protect any record that must not change any more, for example a document that has been approved. The example below locks the quotations that have an approved request. The recipe is the same for every other model.
Go to Settings ‣ Technical ‣ Automation ‣ Automation Rules and click New. Developer mode must be active.
Choose the Model, for example Sales Order.
Set the Trigger:
On create and edit blocks the changes of the record.
On deletion blocks its deletion.
For On create and edit, set the Before Update Domain to the records that are protected. With Approval Requests ‣ Status = Approved, a quotation that has an approved request is protected, whatever model carries the approval. A model that has its own Approval Status field can use it instead. For On deletion, which has no Before Update Domain, set the same condition in Apply on. To protect only some fields, choose them in When updating: a change of any other field passes.
In Actions To Do, add an action Execute Code and write the code that raises the error:
raise UserError("<message for the user>")
Replace the text between the quotes with the message that users read, for example This quotation has been approved and can no longer be changed.
Click Save.
From now on, saving a protected record shows the message and leaves the record unchanged. Create a second rule with the trigger On deletion to protect it from deletion.
Warning
The rule runs for every change of the model, including the changes made by other automation rules and by Viindoo itself. Test it on a few records, and use When updating to limit it to the fields that must stay fixed.
An approval type can also block a transition of the request with a hook. See How to configure approval types as a system administrator.
Send Webhook Notification¶
The rule sends the data of the record to the URL of an external system.
Multi Actions¶
The rule runs several actions one after another. In the Multi Actions window, click Add an action, then choose existing actions of the model, or click New to create a child action.