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.

The Technical menu of Settings with the Automation entries

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.

A new automation rule with its name and the Sales Order model

Trigger

Choose when the rule runs. The triggers are grouped in the list:

The list of triggers of an automation rule
  • 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.

The Before Update Domain and Apply on conditions of an automation rule

Click Edit Domain to write the rules.

The domain window to edit the rules of a condition

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

The window to create an action with the list of action types

Update Record

The rule updates the value of a field of the record. Choose the field and the value.

The Update Record action with the field to update and its new 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.

The Create Activity action with the title Call the customer

Send Email

The rule sends a message to the people concerned by the record.

The Send Email action with its email template and the way to send it
  • 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.

The Add Followers action with the followers to add

Remove Followers

The rule removes followers from the records that meet the conditions.

The Remove Followers action with the followers to remove

Create Record

The rule creates a new record of another model.

The Create Record action with the record to create, its name and the link field
  • 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.

The Execute Code action with the Code and Help tabs

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.

An automation rule on Sales Order, triggered On create and edit, with a Before Update Domain on the approval status and an Execute Code action
  1. Go to Settings ‣ Technical ‣ Automation ‣ Automation Rules and click New. Developer mode must be active.

  2. Choose the Model, for example Sales Order.

  3. Set the Trigger:

    • On create and edit blocks the changes of the record.

    • On deletion blocks its deletion.

  4. 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.

  5. 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.

  6. 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.

The Multi Actions window before any child action is added The window to choose the child actions of the Multi Actions action

See also

Related articles