Перейти к содержанию

Rules for Automation: Example 1

Adding a comment to the workflow request

To allow the initiator to receive information about the progress of a workflow open for a request, you can add automation rules to the tasks within that workflow. For example, an automation rule can be linked to a task for approval, so a comment is added to the request when the status of the approval task is set to ‘Assigned’. This comment informs the initiator that the requested workflow is awaiting approval.

Below are the key elements of such an automation rule.

Trigger

The rule should run after the status of the approval task is changed to ‘Assigned’. Therefore, in the “Trigger” field, select ‘On status update’.

Expressions

The following expressions are defined for the rule. They are used later to define the condition and actions of the rule:

1. is_assigned

The expression is_assigned indicates that the “Status” field of the approval task has a value of ‘Assigned’. It is defined as follows:

  • status = assigned

2. approver

The expression approver is added to retrieve the name of the approver assigned to the task. It is defined as follows:

  • approvals[first].approver

This is the person associated with the first approval record, which is part of the task (i.e., the first approver). As long as this is the first approver, it’s equivalent to:

  • member

This is the first person associated with the task as an approver.

3. request

The expression request is used to find the first request associated with the workflow to which the approval task belongs. It is defined as follows:

  • workflow.requests[first]

This expression can also be defined as:

  • workflow.requests[1]

To find the second request associated with the workflow, the expression has the following form:

  • workflow.requests[2]

The expression to find the last request has the following form:

  • workflow.requests[Last]

or

  • workflow.requests[-1]

4. requester

The expression requester is used to find the name of the person for whom the workflow is being implemented. It is defined as follows:

  • workflow.requests[first].requested_for.name

Another way to define this expression is using the previous expression, which already defines the first request of the workflow:

  • request.requested_for.name

Condition

After defining the expressions, conditions are set for the rule to execute under. In this example, the status of the task should be ‘Assigned’. Since there’s already an expression that is true, the condition has the following form:

  • is_assigned.

This is all that needs to be entered in the “Condition” field for the rule.

Update

The record that needs to be updated is the first request associated with the workflow to which the approval task belongs. This already has an expression – request, so this expression is selected in the “Update” field.

Add Comment

Since we need to add a comment to the request (not set a new value for one of the request fields), we need to change the default option ‘Set’ to ‘Add comment’, which will create a rich text field where we can define the comment for the request. The expressions of the rule can be used in this comment as follows:

Dear {{requester}},

Your request is awaiting approval from {{approver}}