JIRA Automation - Newly created child issue to have parents most recent Fix Version added

Christopher Vickery
Contributor
December 11, 2024

Hi all,

I'm attempting to create an automation rule where a newly created child issue (e.g. story) will automatically take the parents (e.g. Epic) most recent Fix Version.

For example, an Epic contains 4 fix versions - CSP-24.1, CSP-24.2, CSP-24.3, CSP-24.4. The most recent fix version in the list of 4 is the last one added - CSP-24.4.

When a child issue is added to the Epic, preferably it shouldn't pick up all 4 (which is the automation I have in place at the moment). The child issue should only pick up the CSP-24.4 fix version as it's the most recently added in the group. This should only apply to child issues that are not in 'Done' status (as 'done' child issues should not have their fix versions changed after completion).

The releases / fix versions are below:

Fix Versions.png

The example Epics fix versions are below:

Fix Version Epic.png

The rule I've attempted to create is below:

Fix Version Automation Rule.png

When I create a new story under the epic, the audit log is shown below:

Fix Version Audit Log.png

Does anyone know what I'm doing incorrectly? I think it may be the Smart Value in the automation rule.

Thanks for your help.

Chris

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2024

Hi @Christopher Vickery 

There is no list function "latest" to find what you asked.

Assuming the most recent / latest version is always the last one created, you could do this by the ID value (as that is required for the edit):

{{issue.fixVersions.id.max}}

If not, things get more complicated...

Instead you would need to find the maximum releaseDate value in the list of versions selected, and then use dynamic searching methods to extract the ID value:

  1. find the maximum releaseDate with {{issue.fixVersions.releaseDate.max}}
  2. use that to build a dynamic regular expression
  3. expand all the selected values in the Fix Versions field, keeping at least the ID and releaseDate
  4. filter #3 above using inline iteration, the match() function, and the regular expression from #2 above
  5. split apart the result to get the ID

Kind regards,
Bill

Christopher Vickery
Contributor
December 12, 2024

Hi Bill,

Thanks for getting back to me about this.

I've updated the Variable Smart Value to '{{issue.fixVersions.id.max}}' as you suggested.

Unfortunately the most recent created fix Version is still not being added to the newly created child issue.

The audit log is below:

Fix Version Audit Log (2).png

It looks like the branch rule / related issues can't be found for some reason. Which is strange as the branch goes out to the 'children' as expected.

Do you have any other ideas how I can get this working?

Also, thanks for sharing the more complicated resolution. I'm not expert enough to try this!

Thanks,

Chris

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2024

What the audit log shows is the rule is not finding any child issues, so I am unclear what you mean...and that seems unrelated to copying the Fix Version value.

And reviewing your original rule image, one of the conditions checks if the trigger issue is an Epic, Story, Sub-task, or Task...but Sub-tasks cannot have children.

 

Let's confirm your scenario:

GIVEN a parent issue is an Epic, Story, or Task issue type
AND the parent issue has at least one value in the Fix Version field
WHEN an issue is created as a child of the parent issue
THEN copy the most recently created version from the parent issue's Fix Version to the child's Fix Version field

 

How does this compare to your scenario?

 

Christopher Vickery
Contributor
December 13, 2024

Hi Bill,

Thanks for the quick response.

The scenario you've listed is exactly correct. The only additional point is that any existing children of the parent issue that are in 'Done' status should not have their fix versions amended.

So when a child issue is created in the screenshot below, the CSP-25.1 fix version is added to it:

Create Story under Epic.png

Nothing should change for the child issue already in 'Done' status.

The automation rule (including the '{{issue.fixVersions.id.max}}' smart value you recommended is below:

Automation Rule 1.png

Automation Rule 2.png

Thanks again for your help.

Chris

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 13, 2024

Thanks for confirming the scenario!

First thing: unless someone sets the Status to "Done" when the issue is created, one rule will work for this.  A condition may be added to prevent problem.

The key is you to update the created issue from its parent using a lookup rather than a branch as the source, and so let's try this:

  • trigger: issue created
  • action: re-fetch issue
  • condition: status is not equal to Done
  • condition: issue type is one of Story, Task, or Sub-task
  • condition: parent is not empty
  • action: lookup issues, with JQL to find the parent of the trigger issue
    • key = {{triggerIssue.parent.key}}
  • smart value condition: safety check to confirm the lookup found the parent
    • first value: {{lookupIssues.size}}
    • condition: equals
    • second value: 1
  • smart value condition: confirm the parent has a fix version value to use
    • first value: {{lookupIssues.first.fixVersions.id.max}}
    • condition: does not equal
    • second value: leave as empty
  • action: edit issue, setting the Fix Version to
    • {{lookupIssues.first.fixVersions.id.max}}

 

This will work if all of the issues are in the same project.  When the parents (such as an Epic) could be in another project, the rule will need changes to scope and additional conditions.

Christopher Vickery
Contributor
December 16, 2024

Hi Bill,

Thanks for the comprehensive response. 

There still seems to be a slight error somewhere in the process (possibly with the lookup action?). The overall automaton is in 'Success' status but the newly created child issue does not copy the Parents latest Fix Version. I will share the screenshots below:

Fix Version Automation (1).png

Fix Version Automation (2).png

Audit Log:

Audit Log.png

I think we're very close to have this working properly. Really appreciate your help.

Thanks,

Chris

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2024

Oops, you are correct: I had the JQL for the lookup issues action reversed.  It should be:

key = {{triggerIssue.parent.key}}

I updated my earlier post to match.

Christopher Vickery
Contributor
December 17, 2024

This works perfectly! Thanks a lot Bill! :)

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events