How to transition to the previous status of an issue using automation rules in Jira
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
There can be requirements where you would like to transition the issue back to the previous status based on certain conditions. This article would help users to extract the previous status of an issue using automation smart values and a possible workaround for AUTO-473 - [Jira API constraint] More ways to work with issue changelog - allow easy access to issue changelog for determining things like how long an issue has been in the current status, make previous status available for action to rollback a field value.
Environment
Jira Service Management Cloud, Jira Software DC 9.12 and later.
Solution
To be able to transition to the previous status, you would have to capture the previous status details in a custom field so that this can be used at a later point in time to transition the issue.
To capture the value, you can make use of the smart value
{{fieldchange.fromString}}
A. Create two custom fields
- One text field to store the status name ( eg. old status, This can be later used to display the previous status name on the screen, if required)
- One text field to store the status ID (eg. old status ID, This would be required while transitioning the issue to the old or the previous status)
B. Create an automation rule to capture the previous status details:
- Use the Trigger: Field value changed: for the Status field
- Add the Action: Edit issue
- Set old status field to {{fieldChange.fromString}}
- Set old status ID field to {{fieldChange.from}}
- Save this rule.
C. Create an automation rule to transition to the value saved in the above rule.
- Use any trigger based on the requirement.
- Add the action: Transition issue
- Destination status: {{issue.old status ID}}
- Save and run the rule.
Some points to keep note of:
- Ensure to use the status ID while transitioning the issue.
- Add Re-fetch actions, if using the edit issue fields action and the transition issue action in the same rule.