Hello,
I have a rule that is copying FixVersion from Project 1 to Target Quarter in Project 2, when FixVersion is updated. This is working correctly.
I'm using the below to only copy output that have "Q" - The reason for this is that in FixVersion we use ProjectXZY, 25-Q4, 25-Q3, 25-Q2. The below will only copy anything that contains a "Q" -- this is working
{{#triggerIssue.fixVersions}}{{#if(name.contains("Q"))}}{{name}}{{^last}}, {{/}}{{/}}{{/triggerIssue.fixVersions}}
Now I want to modify so if the Output has more then 1 Q then it should updated the Target Quarter field in Project 2, with Needs Attention.
Any help would be appreciated?
I've tried a couple of variations of this, but can't figure it out.
{{#triggerIssue.fixVersions.get(1)}}
{{#if(name.match(".*Q.*"))}}
Needs Update
{{/}}
{{/triggerIssue.fixVersions.get(1)}}
{{^triggerIssue.fixVersions.get(1)}}
{{#triggerIssue.fixVersions.get(0)}}
{{#if(name.match(".*Q.*"))}}
{{name}}
{{/}}
{{/}}
{{/triggerIssue.fixVersions.get(1)}}
Hi @Melissa C
You are trying to perform two filters: find version names containing a "Q", and do something different when more than one is found. I do not believe that can be done in a single step.
I recommend first parsing to get the ones with a "Q", storing the result in a variable:
{{#triggerIssue.fixVersions}}{{#if(name.contains("Q"))}}{{name}},{{/}}{{/}}
Then after removing any trailing comma, use the longer format of if() which supports true and false results. Please note well this version of if() does not have a pound # sign.
{{if(varQuarterlyVersions.substringBeforeLast(",").contains(","), "Needs Attention", varQuarterlyVersions.substringBeforeLast(","))}}
Kind regards,
Bill
Hi @Melissa C,
You're on the right track! Here's a cleaner approach to detect multiple Q versions and set "Needs Attention":
Solution:
{{#with(triggerIssue.fixVersions.where(name.contains("Q")))}}
{{#if(size.gt(1))}}
Needs Attention
{{else}}
{{#each(.)}}{{name}}{{/}}
{{/}}
{{/with}}
How it works:
where(name.contains("Q"))
filters to only Q versionssize.gt(1)
checks if more than 1 Q version existsAlternative approach with counter:
{{#with(triggerIssue.fixVersions.where(name.contains("Q")).size)}}
{{#if(gt(1))}}
Needs Attention
{{else}}
{{#triggerIssue.fixVersions}}
{{#if(name.contains("Q"))}}{{name}}{{/}}
{{/triggerIssue.fixVersions}}
{{/}}
{{/with}}
Test scenarios:
The key is using where()
to filter and size
to count the filtered results.
Need help testing this or have questions about the syntax? Feel free to DM me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the source of your information for this post?
There is no {{else}} expression in smart value, conditional expressions: https://confluence.atlassian.com/automation/jira-smart-values-conditional-logic-1081351607.html
And as a reminder, when posting bot / AI-generated content, that source should be disclosed in the text of a post. For more information, please carefully review the community guidelines: https://community.atlassian.com/forums/custom/page/page-id/rules-of-engagement
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.