update Epic Fix Version from all children when Epic transitions
Asked by Amir Shmulevich:

Hi.

I would like to update an Epic Fix Versions from all children when Epic transitions.

does anyone have any idea how to accomplish?


Answers:
author: Bill Sheboy
body: Hi [@Amir Shmulevich](/t5/user/viewprofilepage/user-id/5592700) -- Welcome to the Atlassian Community!

Please clarify what you are trying to accomplish as it is unclear. And what have you tried thus far to solve the need?

Are you trying to accomplish this:

GIVEN there is an Epic with one or more child issues  
AND the child issues have one or more selected Fix Version values  
WHEN the Epic transitions to status ???  
THEN select the list of Fix Version values from the child issues in the Epic's Fix Version

You do not indicate if the child values should replace any values in the Epic, add to them, or something else. You also do not indicate if the issues are all in the same Jira project

Assuming you want the values replaced and the issues are all in one project, you could first use Lookup Issues to gather the child issues. Then edit the Epic directly to set the values, likely with an iterator and advanced edit with JSON: <https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Fix-Versions>

Kind regards,  
Bill

comments: author: Amir Shmulevich
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , what you are describing is exactly what I am trying to accomplish.

I am looking to replace all fix versions values in Epic with the values from the children.

you answer regarding using the branch was correct - it doesn't work

I couldn't figure out how to accomplish this using lookup issues.


author: Bill Sheboy
body: One challenge with a scenario like this is nested lists: the Fix Versions field is a list of zero-to-many values, for each issue. And there is a list of child issues for the parent Epic. Together that means there could be zero-to-many versions, including possible duplicates selected in the child issues.

But you want the distinct values to set the Epic's field. If the Lookup Issues result contains the child issues for the epic, the list of version names is this:

```
{{lookupIssues.fixVersions.name.join(",").replace("[","").replace("]","").split(",").trim().distinct}}
```

That works by merging the values within each issue's list, removing any nested, list syntax with square brackets, and then reducing the result to remove duplicates. With that you may create a dynamic JSON expression to set the values, as I noted earlier.

* trigger: issue transitioned to your desired status
* condition: issue type is Epic
* action: lookup issues with JQL to gather the child issues of the parent Epic which have Fix Version values
* action: edit issue, using dynamically-built JSON with the above expression and [list iteration](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#Combined-function-examples)

```
{
  "fields" : {
    "fixVersions" : [ 
      {{#lookupIssues.fixVersions.name.join(",").replace("[","").replace("]","").split(",").trim().distinct}}
        { "name": "{{.}}" } {{^last}}, {{/}}
      {{/}}
    ]
  }
}
```

I recommend pausing to understand how that expression works before trying to use it in your rule.

***UPDATED:** I added a trim() call before the distinct one. This will remove leading / trailing spaces from the values, and help to reduce the duplication from the nested lists.*


author: Amir Shmulevich
body: thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , this seems to do the trick.

the only thing I can't figure out now is how to remove space from the fixversion name that I am trying to add.

tried using the .replace(" ", "") in multiple locations - but it has no effect.


author: Bill Sheboy
body: Are the spaces embedded within the version names (and so do not match others) or leading / trailing spaces?

If they are the leading / trailing ones, let's add the trim() function to also prevent potential duplicates: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#trim-->

Please see my updated post above with where to add the trim() call.


author: Amir Shmulevich
body: error message - "Version name '' is not valid (fixVersions)"

for some reason the first value is empty

![Screenshot 2024-09-22 at 20.46.27.png](https://community.atlassian.com/t5/image/serverpage/image-id/348607iFA7910D291117A14/image-size/large?v=v2&px=999 "Screenshot 2024-09-22 at 20.46.27.png")


author: Bill Sheboy
body: Please post an image of your current, complete rule and an image of the audit log details. Those may reveal a problem with the results from the Lookup Issues action.


author: Amir Shmulevich
body: ![Screenshot 2024-09-22 at 22.03.27.png](https://community.atlassian.com/t5/image/serverpage/image-id/348610i7FD0DAF2A5E8BA32/image-size/large?v=v2&px=999 "Screenshot 2024-09-22 at 22.03.27.png")![Screenshot 2024-09-22 at 22.03.58.png](https://community.atlassian.com/t5/image/serverpage/image-id/348609i866B1AC670453D6B/image-size/large?v=v2&px=999 "Screenshot 2024-09-22 at 22.03.58.png")


author: Bill Sheboy
body: One or more of the child issues in your Epic has no Fix Versions assigned. If that was expected, the fix to handle the case is to change the JQL for the lookup to exclude them:

```
"Epic Link" = {{issue.key}}?AND fixVersion IS NOT EMPTY
```

If it is possible none of the issues in the Epic have values, I recommend adding a condition after the Lookup Issues action so the rule will not proceed.


author: Manoj Gangwar
body: Hi [@Amir Shmulevich](/t5/user/viewprofilepage/user-id/5592700) Welcome to the community!

To automatically update an Epic's Fix Versions based on its child issues' Fix Versions when the Epic transitions, you can set up a Jira Automation rule. Here's how you can achieve this:

Steps to Set Up the Automation Rule:

Go to Jira Automation:

In Jira, navigate to Project Settings \> Automation (or Global Automation if you want this to apply to all projects).

Create a New Automation Rule:

Click on Create Rule.

Set the Trigger:

Select the Issue Transitioned trigger.

Configure it to trigger when the Epic transitions to the desired status (e.g., "Done" or any other transition you're interested in).

Add a Branch for Child Issues:

After the trigger, add a Branch rule/related issues action.

Choose For Epic's stories (or other child issues). This ensures that the rule will act on all issues linked to the Epic.

Add Action to Copy Fix Versions:

After the branch, add a Lookup Issues action. In the JQL query, use the following query to fetch all child issues of the Epic:

"Epic Link" = {{issue.key}}

Next, add a Create Variable action. Define a variable like childFixVersions and use the following smart value to collect the Fix Versions from the child issues:

{{lookupIssues.Fix Versions.distinct}}

Update the Epic's Fix Versions:

After the child issues are fetched, add a Edit Issue Fields action.

Set the Fix Versions field to the value of the childFixVersions variable you created:

{{childFixVersions}}

Save and publish the rule.

comments: author: Amir Shmulevich
body: thanks. I followed your instructions and created the automation.

but when I sent the data in the {{childFixVersions}} I am getting the child issue keys and not the fix versions.

did I miss anything?

![Screenshot 2024-09-15 at 16.08.35.png](https://community.atlassian.com/t5/image/serverpage/image-id/347431iCBF3E450889BCE49/image-size/large?v=v2&px=999 "Screenshot 2024-09-15 at 16.08.35.png")


author: Manoj Gangwar
body: It sounds like the {{childFixVersions}} variable is capturing the child issue keys instead of the Fix Versions. This likely happened because lookupIssues by default returns the full set of issues, and if you're using the smart value incorrectly, it may be referencing the issue keys.

To fix this and properly extract the Fix Versions from the child issues, you can refine the smart value syntax to target the specific field (Fix Versions). Here's how you can adjust it:

In the Create Variable Action: The variable childFixVersions should reference the Fix Versions field of the child issues. Fix Versions is a multi-select field, so to capture it properly from all child issues, modify the smart value like this:

{{#lookupIssues}}{{Fix Versions.name}},{{/}}

This will iterate over each issue in lookupIssues and extract the Fix Versions by name.

If you want to remove any duplicates, you can apply the distinct function:

{{lookupIssues.Fix Versions.name.distinct}}

This will gather only the unique Fix Versions from all child issues.


author: Amir Shmulevich
body: when I changed the lookup value from "Epic Link" = {{issue.key}} to "Epic Link" = {{issue.parent.epic.summary}} - I started getting the fixVersion in my variable.

the value I see for the {{childFixVersions}} is "5, 6,5, 6,3, 4,"

but it is still not getting updated in the Epic fixVersions field. and the Epic fixVersions field is being deleted instead of updated.


author: Manoj Gangwar
body: It seems like you're almost there! You're now correctly capturing the Fix Versions from the child issues, but the formatting of the {{childFixVersions}} value is causing the Epic's Fix Versions field to be deleted instead of updated. The issue lies in how the values are being processed and fed into the Fix Versions field.

You can fix this by:

Removing duplicates.

Cleaning up the comma-separated list.

Ensuring the format matches what Jira expects for multi-select fields.

Here's the Correct Approach:

1. Use the distinct and join Smart Value Functions

To ensure that the Fix Versions list is unique and formatted correctly, update the smart value for childFixVersions to use both distinct and join functions:

{{lookupIssues.Fix Versions.name.distinct.join(",")}}

This will:

Remove duplicates using distinct.

Combine the Fix Versions into a comma-separated list with no extra commas or spaces using join(",").


author: Bill Sheboy
body: Hi...

Creating a variable inside of a branch which could be on more than one thing will not work for this scenario. Such branches run in parallel and asynchronously, and thus the variable will repeatedly go out of scope. After the branch, the variable is not available.


Tags: cloud

jira-automation

jira-cloud