Forums

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

Adding FixVersions to Parent/Epic

Toni Duer April 3, 2024

Hello! I am trying to add fix versions to the parent/epic from the trigger issue. My trigger is when the fix version value changes on a story/bug/task. I have a branch to check that a parent exists and then to modify the parent using the JSON below:

{
"update": {
"fixVersions" : [
{
"add": {
"name":"{{triggerIssue.fixVersions.name}}"
}
}
]
}
}

I have referenced many other articles and resources such as https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/ but I think somewhere I am missing a step. My audit log sjhows that its hitting an error when it tries to edit the parent: (Specify a valid value for fixVersions (fixVersions)).

 

2 answers

1 accepted

2 votes
Answer accepted
Kalyan Sattaluri
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.
April 3, 2024

Hello @Toni Duer 

Is your Parent epic in the same project as trigger issue?

Toni Duer April 3, 2024

It is in the same project.project.PNG

Kalyan Sattaluri
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.
April 3, 2024 edited

Hello,

If your trigger issue has more than 1 fixVersion, then we have to format the JSON..

Before Branch,

Create a variable, call it myvar assign it  {{#issue.fixVersions}}{{name}}{{^last}},{{/}}{{/}}      [see screenshot]

Then in your advanced edit, use below smart value:

{ "update": { "fixVersions": [ {{#myvar.split(",")}}{ "add": {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ] } }

 

Basically, above syntax will render the JSON like below:

{ "update": { "fixVersions": [ { "add": {"name" : "R2021.02" }}, { "add": {"name" : "NoCD-23044" }} ] } }
which is the right syntax when you can have multiple fix versions.
Hope it helps.

 

image.png

 

Like • Benjamin Horst likes this
Toni Duer April 3, 2024

Thanks! I added the new variable. Do I need to reference the new variable in my JSON later when I edit issue fields or will that stay the same?

Kalyan Sattaluri
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.
April 3, 2024

When editing the field, your JSON should be like below, replace bolded part with your variable name.

 

{ "update": { "fixVersions": [ {{#myvar.split(",")}}{ "add": {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ] } }

Toni Duer April 3, 2024

Thank you so much! It works! Is there a "remove" function that works similar to "add" in the JSON for when a fix version is removed instead of added?

Kalyan Sattaluri
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.
April 3, 2024 edited

Great.

If you want to implement to add or remove logic.. your rule needs more steps.

Basically,

{{changelog.Fix Version.fromString}}  <-- Gives you items removed

{{changelog.Fix Version.toString}}     <-- Gives you items added

Then, {{changelog.Fix Version.fromString.size}} gives you items were removed or not, same with {{changelog.Fix Version.toString.size}}

So you implement if conditions first to determine if items were removed and/or added. (see screenshot further below)

Inside each if condition, you will implement same rule we mentioned, with few changes on where to get the added / deleted values.

To add fixversions,

Inside if condition, you create variable (myvar) and assign it below smart value:

{{#changelog.Fix Version}}{{fromString}}{{^last}}, {{/}]{{/}}

Then edit issue with below JSON:

{ "update": { "fixVersions": [ {{#myvar.split(",")}}{ "add": {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ] } }

 

To remove fixversions,

Inside if condition, you create variable (myvar) and assign it below smart value:

{{#changelog.Fix Version}}{{toString}}{{^last}}, {{/}]{{/}}

Then edit issue with below JSON:

{ "update": { "fixVersions": [ {{#myvar.split(",")}}{ "remove": {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ] } }

image.png

 

Hope it helps and if you think your answer was resolved, please consider accepting solution so others can benefit.

Toni Duer April 3, 2024

Absolutely, this has been so helpful. Thanks again!

Benjamin Horst
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.
August 12, 2024

Thank you @Kalyan Sattaluri

this helped me a lot after I tried to use {{triggerIssue.fixVersions.name}} (which gave me the all Versions as one combined String and {{#triggerIssue.fixVersions.name}} (which just throws an Error). 

Like • Kalyan Sattaluri likes this
0 votes
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.
April 3, 2024

Hi @Toni Duer and @Kalyan Sattaluri 

Please note the {{fromString}} and {{toString}} values for the changelog of Fix Versions could overlap in values, and...

There could be inconsistencies due to this known defect for changelog accuracy of list fields such as Fix Versions and Sprints: https://jira.atlassian.com/browse/JRACLOUD-80486  This defect is worsened as apparently not all of the UX paths to change / create Fix Versions are tracked in the changelog.

At this time, there is no known work-around for this defect.  The severity and priority were recently increased, so perhaps this will be finally fixed.

 

For a mitigation, you may try:

  • removing all existing values from the field
  • re-fetch the issue
  • add all of the new ones

 

Kind regards,
Bill

Kalyan Sattaluri
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.
April 3, 2024

Oh wow. Thanks @Bill Sheboy  Went and checked and {{changelog.Fix Version.toString}} is definately broken and {{changelog.Fix Version.fromString}}  "seems" to be working but I havent checked thoroughly. Thank you and will be mindful go forward.

@Apologies @Toni Duer  given this news, may have to rethink if you want to handle removes or just sync child stories to parents.. Cause blanket syncing which you have already/first implemented should be working. Just this nuanced pick and choose part seems to be broken from Jira..

Like • Bill Sheboy likes this
Toni Duer April 4, 2024

@Bill Sheboy @Kalyan Sattaluri Good to know! Thanks for the update.

Like • Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events