Automation Rules: Example 4
Creating a reprocessing cycle in a workflow
If a task cannot be completed, the status of the previous tasks is not updated to ‘Assigned’ and the workflow status changes to ‘Process Suspended’. The workflow manager makes a decision to resume execution. For some workflows, this always means re-processing a previously completed task.
In this example, there are 3 tasks that need to be performed sequentially.:
- Develop a new release
- Submit a new release for testing
- Test the new release
- Submit a new release for testing
If the third task is not completed, the workflow manager plans that the automation rule will set the status of the first task back to ‘Assigned’ and the other two to ‘Registered’, which will ensure that the workflow returns to the first task.
The following describes how a workflow manager can identify the basic elements of such an automation rule.
Trigger
Since the rule must be executed after the status of the third task has been changed to ‘Failed’, the option ‘Status update’ is selected in the Trigger field.
Expressions
The following expressions are defined for the rule, which are later used to define the rule condition and the actions performed by it.:
1. has_failed
The expression has_failed indicates that the Status field of the third task has the value ‘Failed'. It is defined as follows:
status = failed
2. note
The expression note is needed to search for a comment that is added to the third task when its status changes to ‘Failed’. This is the last comment on the task, and it describes the reason for the failure. Such an expression is defined as follows:
note[last].text
3. develop_task
The expression `develop_task' is used to identify the task of developing a new release. The topic of such a task is ‘Develop a new release’, respectively, the expression is defined as follows:
workflow.tasks['Develop a new release']
4. transfer_task
The expression `develop_task' is used to identify the task of submitting a new release for testing. The topic of such a task is ‘Submit a new release for testing’, respectively, the expression is defined as follows:
workflow.tasks['Submit a new release for testing']
Condition
After defining the expressions, the rule is given the conditions under which the rule is executed. In this example, the task status should be ‘Failed'. Since there is already an expression for this, the true condition looks like this:
has_failed
This is all that needs to be added to the rule condition.
Update 1
The first action performed by the rule is to add a comment to the development task, which will inform the developer of the reason for reopening the task. The expression develop_task has already been set for this task. This expression is selected in the "Update" field.
Add a comment
Since the first action adds a comment to the development task, you need to change the default option ‘Set ’to ‘Add Comment'. In this case, a text field will appear for entering a comment. To add the last comment left for an unsuccessful task, you can use the expression defined for the last comment in the comment you create:
The new release failed testing:
{{note}}
Update 2
The second action performed by the rule is to reopen the development task. To execute it, the expression develop_task is set in the "Update" field.
Ask
Since the second action changes the status of the development task back to ‘Assigned’, the following is indicated in the 'Set' field:
status = assigned
Update 3
The third action performed by the rule is updating the test transfer task. To execute it, the expression transfer_task is set in the "Update" field.
Ask
Since the third action changes the status of the task to ‘Registered’, the following is indicated in the 'Set' field:
status = registered
Update 4
The fourth action performed by the rule is updating the status of the test task. Since this is a task for which an automation rule is defined, there is no need to set any value in the "Update" field. By default, it will match the current record (i.e. the test task).
Ask
Since the fourth action changes the status of the test task back to ‘Registered’, the following is indicated in the 'Set' field:
status = registered
Update 5
The fifth action performed by the rule is updating the status of the workflow, which was set to ‘Process suspended’ after the failed completion of the testing task. To update the workflow, it is enough to specify workflow in the "Update" field.
Ask
In order for the fifth action to return the workflow status to the value ‘Implementation’, the following is indicated in the "Set" field:
status = implementation