Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy on certain fix versions from an Epic to its child?

Patrick Cartier March 4, 2025

The Epic to child part is fairly simple.

The difficult part and one that I am struggling with currently is only copying certain fix versions from the Epic's Fix Version field.

Let's say Epic-1 has Fix Versions "ABC 2024" and "123 2024." I would like to copy only the "ABC 2024" Fix Version and not the "123 2024" Fix version.

Any ideas?

 

1 answer

0 votes
Vishal Biyani
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.
March 4, 2025

@Patrick Cartier 

Do you have specific rules for exclusion? if so, you can iterate through the list of fixVersions and if they match the rules for exclusion then don't append in Epic else append it.

Patrick Cartier March 4, 2025

Let's say the rule is if the fix version doesn't contains ABC then don't append it and if it does then append it.

Is that enough of an exclusion rule?

Vishal Biyani
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.
March 4, 2025

Iterate over fixVersions

{{#issue.fixVersions}}

if(name.match("*(ABC)*"), <True do something>, <False do other logic>)

{{/}}

 

see if this works for you

Patrick Cartier March 5, 2025

For the true and false sections, how would I copy that specific fixversion name if true and do nothing at all if false?

Vishal Biyani
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.
March 6, 2025

@Patrick Cartier 

Here is my proposed solution. see if this works for you.

As a trigger I have used Manul trigger. You can use as per your use case

1)

Create smart variable say varFilteredFixVersions. This creates a json object for matching fixVersions that need to be copied to child issue from epic.

{{#issue.fixVersions}}

{{#if(name.indexOf("ABC").eq(-1))}}

{"name": "{{name}}"},

{{/}}

{{/}} 

2) Create a branch for Children

3) Then Edit issue select fixVersions to edit and in the advanced edit code box, put

{
"fields": {
"fixVersions": [ {{varFilteredFixVersions.substringBeforeLast(",")}} ]
}
}

Patrick Cartier March 6, 2025

The result here is {"name": "non-abc fixversion"}

Vishal Biyani
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.
March 6, 2025

varFilteredFixVersions.substringBeforeLast(",") would have something like that.

So all the fixVersions in Epic and doesn't contain ABC, will be/should be added in child stories/task

if you need to reverse i.e. only copy where ABC is present then change eq to gt and that should work

{{#if(name.indexOf("ABC").gt(-1))}}

Patrick Cartier March 7, 2025

The reverse works well for my case, but right now it is still printing 

 

{"name": "ABC fixversion"}

 

Vishal Biyani
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.
March 7, 2025

can you share the screenshot of the automation that you have?

and where it is breaking

so, if you have fixVersions like "ABC 2024", "123 2024", "2025 ABC" in the epic then ideally both "ABC 2024" and "2025 ABC" should get copied to child.

Patrick Cartier March 7, 2025

The error I am currently getting is 

Unable to find any issue field values to edit:

This is the JSON for settings fixversion 

{

"add": {

"fixVersions": [

{"name": "{{varabcfixversion.substringBeforeLast(",")}}"}

]

}

}

And this is the code for the variable creation (varabcfixversion)

{{#issue.fixVersions}} {{#if(name.indexOf("ABC").gt(-1))}} {{name}}, {{/}} {{/}}  

 With an audit entry immediately after, I can print the correct fixversion

{{varabcfixversion.substringBeforeLast(",")}}

 But I get the error I mentioned above.

Vishal Biyani
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.
March 7, 2025

this is the automation that I wrote. In the edit action, assumint you selected fixVersion field, i see the use of json in Additional fields may not be correct.

Can you try with what i have in screenshot i.e. additional fields text box should look like

{
"fields": {
"fixVersions": [ {{varFilteredFixVersions.substringBeforeLast(",")}} ]
}
}

 

snip.png

Patrick Cartier March 7, 2025

@Vishal Biyani leaving the field blank like that clears the value. We can't have both the field and the advanced edit.

Vishal Biyani
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.
March 7, 2025

No. it doesn't. Otherwise, there is no purpose of Advanced fields.

You need to select the field as far as i know. Otherwise, automation will give the error that you are seeing.

Try it out with one test issue that you may have and see how it goes.

Patrick Cartier March 7, 2025

I did, and it clears the value when I do that.

I am getting closer with this though, but it adds a space " " before the fixversion

Any ideas?

{
"fields": {
"fixVersions": [
{"name":
"{{varabcfixversion.substringBeforeLast(",")}}"
}
]
}
}
Vishal Biyani
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.
March 7, 2025

not sure why a space will get added. How can you try using trim() to see if removes the leading and trailing spaces.

if this does not do the problem, check if there is an extra space added somewhere by mistake?

Patrick Cartier March 10, 2025

trim() worked great and this is working very well right now. Thank you @Vishal Biyani .

If I wanted to extend this a bit further, how could I do the same but with multiple ABC fix versions? So if an issue has three versions "ABC 123", "ABC 456", and "Example version." I would only want to copy the first two.

Let me know if this is possible. Thanks again for all your help!

Vishal Biyani
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.
March 10, 2025

Good to know that you are able to make progress.

 

JIRA Automation has a limitation that you can't have nested branches. 

Therefore, the way I put the logic together was in the smart variable varFilteredFixVersions create pairs of name and fixVersion as a json string 

like 

{"name": "ABC 123"}, {"name": "ABC 456"},

{{#if(name.indexOf("ABC").gt(-1))}} {"name": "{{name}}"}, {{/}} {{/}}

For JSON to be valid, you can't have trailing ,. Therefore, when doing advanced edit, the string before last , was read. 

{
"fields": {
"fixVersions": [ {{varFilteredFixVersions.substringBeforeLast(",")}} ]
}
}

 

This way you get below json and all applicable fixVersions are updated.

{
"fields": {
"fixVersions": [ {"name": "ABC 123"}, {"name": "ABC 456"} ]
}
}

 

See if you can adjust the logic this way

Patrick Cartier March 14, 2025

The 

{{varFilteredFixVersions.substringBeforeLast(",").trim()}} 

produces exactly what we need like you said 

{"name": "ABC 123"}, {"name": "ABC 456"}"

 but the JSON you have provided returns

Error while parsing additional fields. Not valid JSON.

We are very close. I'm continuing to tinker with it 

Suggest an answer

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

Atlassian Community Events