Forums

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

Jira Automation: Copy linked issue's Fix Versions to triggerIssues Affects Versions field.

Jonny March 10, 2025

Hey, I'm planning a trigger automation to pull out the Fix Versions from the triggerIssue's linked issues and then add those Fix Versions to the Affects Versions of the triggerIssue. Screenshot 2025-03-11 at 2.06.11 pm.png

I'm getting stuck quite early, I can't seem to format the values coming from lookupIssues well enough. Nor can I get the formatting of the advanced editing action to be right.

As well as I'd need to consider multiple linked issues, and multiple fixVersions too. 

Am I overthinking this? 

 

Thanks, any help is plenty appreciated.

2 answers

2 accepted

5 votes
Answer accepted
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

@Jonny 

FixVersion and Affects Versions are a list field.

You can start by creating a variable and create a json string of matching fixVersions like this

{{#lookupIssues.fixVersions}} {"name": "{{name}}"}, {{/}}

Then when you edit the fixVersion use something like

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

see if you are able to make progress with this logic

Jonny March 10, 2025

Thanks so much Vishal.

 

Works like a gem. 

Jonny March 11, 2025

Hey Vishal, thanks for your help with this one. I changed the method to a Scheduled Job (makes more sense in my head), and the job failed with an invalid json structure. I'll give Bill's method a try to see if that solves it. 

2 votes
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.
March 11, 2025

Hi @Jonny 

When trying to extract the distinct versions from a Lookup Issues result, please consider that the Lookup Issues result is a list of issues and the Fix Versions field is a list.  Thus a list of lists will appear like this: [version A, version B], [version B], [], [version C]...  Adding that directly will attempt to add duplicate values to the Affects Versions field or fail in the JSON.

 

To extract the distinct values spanning all of the issues in the lookup result, the newly revealed flatten function may be used with the distinct function:

{{lookupIssues.fixVersions.name.flatten.distinct}}

That list may then be iterated to create a dynamic JSON expression to add them:

{
"fields": {
"versions": [
{{#lookupIssues.fixVersions.name.flatten.distinct}}
{
"name": "{{.}}"
} {{^last}},{{/}}
{{/}}
]
}
}

 

Kind regards,
Bill

Jonny March 11, 2025

Thanks Bill, I'll give this method a try too.

Like Bill Sheboy likes this
Jonny April 3, 2025

Hey @Bill Sheboy

This has been working really well for us. I was just wondering if you had any idea of how I could add a condition to only include versions that are either unreleased or release, i.e. explicitly NOT archived?

 

Thanks, 

Jonathon.

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 6, 2025

Hi @Jonny 

That would require an extra step for this scenario to filter for the desired state first, storing the results in a created variable.  For example:

  • action: create variable
    • name: varNotArchivedVersions
    • value:
{{#lookupIssues}}
{{#fixVersions}}
{{#if(not(archived))}}{{name}},{{/}}
{{/}}
{{/}}
{
"fields": {
"versions": [
{{#varNotArchivedVersions.substringBeforeLast(",").split(",").distinct}}
{
"name": "{{.}}"
} {{^last}},{{/}}
{{/}}
]
}
}

 

Like Jonny likes this

Suggest an answer

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

Atlassian Community Events