Xurrent Help

Automation Rule Example 3

Cancel a Task Using the UI Extension Data of a Request

When a workflow is opened for a request with a UI extension, the field values of this UI extension may indicate that one of the tasks of the workflow does not need to be completed. In such cases, an automation rule can be used to cancel this task.

The following sections describe the key parts of such an automation rule.
 

Trigger

Because the rule needs to be executed when the workflow is planned, it will probably be included in one of the risk & impact analysis tasks. As soon as the status of this task has been set to ‘Assigned’, the rule can cancel an implementation task if it is not needed. The option ‘On status update’ is therefore selected in the Trigger field.
 

Expressions

Assuming that the task for installing a telephone is not needed if a phone was not requested in the UI extension, the following expressions are defined for the rule so that they can subsequently be used to define the condition for the rule, as well as the actions that it needs to execute:

1. is_assigned
The expression is_assigned specifies that the Status field of the approval task is set to ‘Assigned’. It is defined as follows:

  • status = assigned

2. phone

The expression phone is added to check whether a telephone was requested in the UI extension of the first request of the workflow. The field values of a UI extension are stored in the custom_fields field. If we assume that the UI extension has a checkbox that needs to be checked to order a telephone and that this checkbox has the field identifier phone, the expression is defined as follows:

  • workflow.requests[first].custom_fields.phone

3. phone_task

The expression phone_task is used to identify the task that needs to be canceled if a telephone was not requested. If the subject of this task is ‘Install a new fixed-line telephone’, the expression is defined as follows:

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

Condition

After the expressions have been defined in the rule, the condition, which needs to be met in order for the rule to be executed, can be set. In this example, the status of the task needs to be ‘Assigned’ and the phone field of the UI extension of the request needs to be ‘false’. There are already 2 expressions that can be used for this, so the condition that needs to be met is simply:

  • is_assigned and !phone
     

Update 1

The record that needs to be updated is the task that needs to be canceled. Again, there is already an expression for this. That is the expression phone_task. This expression can therefore be selected in the Update field.
 

Set

Because the objective is to cancel a task, the default option ‘Set’ can be used for the first action of this rule. This first action needs to set the status of the task to ‘Canceled’. This is done as follows:

  • status = canceled
     

Update 2

Because the Note field is required when the status of a task is set to ‘Canceled’, another action needs to be executed by the rule to successfully cancel the phone_task. After clicking on the ‘Add Action…’ option, the Update field of this second action can also be set to the expression phone_task.
 

Add note

For this second action of the rule, the default option ‘Set’ needs to be updated to ‘Add note’. This provides a rich text field in which the note for the canceled task can be defined as follows:
 

This task was canceled because a telephone was not requested for the new employee.

 

Demo Data

This example can be found in the ‘Information Technology – Widget North America’ account of the Xurrent demo data. It is included in the risk & impact analysis task template of the workflow template ‘Prepare services for new employee’. To review this example, log into your Xurrent demo instance at Xurrent-demo.com by entering the name and password of the instance. Once you have accessed your instance, select the Xurrent account ‘Information Technology – Widget North America’. Next, log in as Karri Otter (email address: karri.otter@widget.com and password: Xurrent). When you are logged in as Karri, you can open the workflow template in the Records console.