Automation for Jira - how to trigger a rule when a Sub-task's Parent changes (sub-task is moved)
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server 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
Purpose
This guide explains how to run an Automation for Jira (A4J) Server/Data Center rule when a sub-task moves from one parent to another. For example,
- Story A
- Subtask A
- Story B
- (Subtask A moved here)
Environment
- Jira Server/Data Center on any version from 8.0.0
- Automation For Jira on any version from 7.0.0
Solution
In A4J, the "sub-task moved parent issues" event is Issue Edited. The way we can track the sub-task moved is via the changelog Smart Value
Therefore, we can create a rule as follows:
- When: Issue updated
- This is the trigger for "sub-task moved"
- If: Issue Type equals "sub-task"
- Check if the sub-task issue type triggered the rule
- And: Advanced compare condition:
- Check if:
- {{changelog.Parent Issue.fromString}}
- Does not equal:
- {{changelog.Parent Issue.toString}}
- This uses the change log smart value to check the "Parent Issue" change log entry and compare the "from" and "to" strings. If it does not match, then we know that the Sub-task has moved.
- Check if:
- (example) Then: Add comment to the issue
- You can reference the smart values for issue.key (subtask that got moved), changelog.Parent Issue.fromString (original parent) and changelog.Parent Issue.toString (new parent)