Right now I have a simple automation....when an issue is transitioned from "not ready" to "ready" then do an audit log action.. in that action i have the following:
{{#if( (issue.parent.fields.customfield_12521.join(",").contains("XYZ") and issue.fields.fixVersions.join(",").contains("ABC")) or (not(issue.parent.fields.customfield_12521.join(",").contains("XYZ")) and not(issue.fields.fixVersions.join(",").contains("ABC"))) )}} Pass {{else}} Fail {{/}}
This allows me to save the automation but when it runs I get this error..
{{#if( (issue.parent.fields.customfield_12521.join(",").contains("XYZ") and issue.fields.fixVersions.join(",").contains("ABC")) or (not(issue.parent.fields.customfield_12521.join(",").contains("XYZ")) and not(issue.fields.fixVersions.join(",").contains("ABC"))) )}} Pass {{else}} Fail {{/if}}
which doesnt even let me save the automation and gives me this error..
Error parsing template: Closing tag (if) does not match opening tag (if( (issue.parent.fields.customfield_12521.join(",").contains("XYZ") and issue.fields.fixVersions.join(",").contains("ABC")) or (not(issue.parent.fields.customfield_12521.join(",").contains("XYZ")) and not(issue.fields.fixVersions.join(",").contains("ABC"))) ))
Any help would be greatly appreciated..
Hi @dsaveri -- Welcome to the Atlassian Community!
Short answer: the syntax you are using is incorrect for logical conditions. I recommend pausing to review the syntax, and then incrementally creating your conditions, storing the results in created variables and writing them to the audit log for testing. Once they are working as expected, try merging them and re-testing.
For more information...
You are using incorrect syntax for conditional statements: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#if
First, there is no {{else}} clause. When you want to use such a format, please try:
{{if(smartValue, "value if true", "value if false")}}
Please note well: when using this format, there is no pound sign # before the if() function.
Next, that if() format has limited abilities to perform other functions or use smart values. Which is why the way you are using the AND() and OR() functions will not work:
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#and
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#or
Based upon what you show, a text description of what you are trying is this:
IF (
issue.parent.customfield_12521.join(",").contains("XYZ")
AND issue.fixVersions.join(",").contains("ABC")
)
OR (
NOT ( issue.parent.customfield_12521.join(",").contains("XYZ") )
AND NOT ( issue.fixVersions.join(",").contains("ABC") )
)
)
THEN
Pass
ELSE
Fail
As written, that will not work for several reasons...
When an automation rule accesses the smart values for the connected issues, it only loads a few of their fields, such as Key, Summary, Status, etc. These connected issues, smart values include at least: {{issue.parent}}, {{issue.subtasks}}, and {{issue.issuelinks}}
If instead the rule pulled in all of the data for those issues, you could easily imagine their connected issues would pull in others, in an ever increasing tree of potentially thousands of issues! When you want other than the basic fields in the connected issues, use the Lookup Issues action with JQL to load the data for those issues, such as the parent, and then use the {{lookupIssues}} smart value in the rule.
Smart values which have several attributes, such as Fix Versions, have a default one provided. For {{issue.fixVersions} that is the ID of the version. And so this will produce a list of numbers and not the names of the versions:
{{issue.fixVersions.join(",")}}
When you want the names of the versions, add that attribute:
{{issue.fixVersions.name.join(",")}}
Kind regards,
Bill
Hello @dsaveri
Welcome to the Atlassian community.
Have you considered/tried using the "IF or ELSE" condition structure rather than using code?
Is this related to your other post here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it is somewhat related but very focused question.
I will need to do actions based on the output of the if else. So I would have to repeat all actions for if and then again for else then that would be for 30 different conditions.. Seems unwieldy, so Im trying to "simplify" it to a single conditional to output one way or another. Once I have this working I have a path forward.. If you have hesitations for using an if / else statement vs a condition structure, please let me know your thoughts.
I havent had much luck with if /else syntax working correctly. But also having problems with 2 condition if conditions.. if you can provide a couple examples of each using the correct syntax that will go a long way
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.