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

Rules for Automation: Example 3

Canceling a task via UI extension data request

When a workflow opens for a request with a UI extension, the values in the fields of this UI extension may indicate that one of the workflow tasks should not be performed. In such cases, you can use an automation rule to cancel that task.

Below are the main elements of such an automation rule.

Trigger

Since the rule should run when a workflow is scheduled, it will likely be included in one of the risk and impact analysis tasks. Once the status of this task changes to ‘Assigned’, the implementation task will be canceled if it’s not needed. Therefore, the “Trigger” field is set to ‘On Status Change’.

Expressions

Let’s assume that if a phone isn't requested in the UI extension, then the installation task should not be performed. The following expressions are defined for this rule, which are used later to determine the conditions and actions of the rule:

1. is_assigned

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

  • status = assigned

2. phone

The expression phone is added to check if a phone was requested in the UI extension for the initial workflow request. The values in the fields of the UI extension are stored in custom fields. Suppose there’s a checkbox in the UI extension that needs to be checked to order a phone, and this checkbox has an identifier of the field phone, then the expression is defined as:

  • workflow.requests[first].custom_fields.phone

3. phone_task

The expression phone_task is used to identify the task that should be canceled if a phone wasn’t requested. If the task's topic is ‘Install a new fixed-line telephone’, the expression is defined as:

  • workflow.tasks['Install a new fixed-line telephone']

Condition

Once the expressions are defined, the rule is given conditions under which it should run. In this example, the task's status should be ‘Assigned’, and the phone field in the UI extension for the request should be ‘false’. Since these are already covered by two expressions, the complete condition is:

  • is_assigned and !phone

Update 1

The record to update is the task that requires cancellation. The expression phone_task already exists for this, so it is selected in the “Update” field.

Set

Since the goal is to cancel the task, the first action of this rule can use the default option ‘Set’. This will set the status of the task to ‘Canceled’. The expression looks like this:

  • status = canceled

Update 2

Since setting the task status to ‘Canceled’ requires a “Comment” field, another action needs to be added to the rule for successful cancellation. Select the default option ‘Add Comment’ and set the expression phone_task in the “Update” field of this second action.

Add Comment

For the second action of the rule, change the default option ‘Set’ to ‘Add Comment’. This will create a text field for adding a comment to the canceled task, which looks like this:

  • This task was cancelled because a phone wasn’t requested for the new employee.