Forums

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

Smart value conditional - equals prints true, not intended string

Arild Hoyland August 30, 2023

I have the following snippet:
{{ if(equals(issue.issueType.name, "Task"))}}
TASK
{{ /}}
{{ if(equals(issue.issueType.name, "Bug"))}}
BUG
{{ /}}

Which I assume should work, following the syntax and example found here: 
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/#equals
{{if(equals(issue.assignee, issue.reporter))}}
Assign this issue to someone else so they can review.
{{/}}

 

But in my case the strings 'TASK' and 'BUG' are printed no matter what. The first if-statement also prints 'true', while the second doesn't print false (which is correct, my test issue has type = "Task").

Am I doing something wrong here? This is all run within an automation rule (web request, custom data, body, description field for a POST API call).

The space I've added before 'if' and the closing '/' at the end are necessary otherwise I get an error stating there's an issue with smart value expression.

 

 

1 answer

1 accepted

1 vote
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.
August 30, 2023

Hi @Arild Hoyland -- Welcome to the Atlassian Community!

First thing, context is important for automation rules.  For a question like this, please consider also posting images of the complete rule and audit log details showing the rule execution.  That can help see where the symptom is appearing in the rule execution.  Thanks!

Without seeing those...Please try these in your rule:

{{#if(equals(issue.issueType.name, "Task"))}}TASK{{/}}
{{#if(equals(issue.issueType.name, "Bug"))}}BUG{{/}}

The documentation on conditional logic has lots of typos/errors on that page, including the missing pound signs for some rule structures.

Kind regards,
Bill

Arild Hoyland August 31, 2023

Hi Bill,

thanks a lot, your suggestion solved my issue. Thought I'd tried all syntax permutations, but clearly not.

Since I see your name a lot around these parts regarding smart values, any idea why this one doesn't work?

{{#issue.labels}}
    {{#if(equals(name, "Fasttrack"))}}Spesialfunksjonalitet{{/}}
{{/}}

I want to loop through all labels on a given issue, check if one of those has the name "Fasttrack", and then print the given string.

Atm this isn't giving me any errors, but it's not printing the specific string when issue has the given label. 

Any ideas?

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.
August 31, 2023

I am glad to learn that helped!  Please consider marking this question as "answered" as that will help others looking for similar solutions.  Thanks!

For your next question...although I hypothesize labels have attributes behind the curtain, the only things we can see in rules (or the REST API) are the values.

When you want to list-filter on something that only has values, we cannot filter on {{.}} which is what represents the value.  Instead the filtering is smart enough to figure it out this way:

{{#issue.labels}}{{#if(equals("Fasttrack"))}}Spesialfunksjonalitet{{/}}{{/}}

  

Like Benavides, Fernando likes this
Arild Hoyland September 1, 2023

Amazing Bill, what would I do without you? :D 

Final challenge now -- I don't actually wish to type out "spesialfunksjonalitet", instead I want to write {{variable.spesialfunksjonalitet}} -- this is a variable which the external system of which API I'm calling will look up. 

Obviously this causes confusion, because Jira is interpreting this as a Jira smart value. Is there any way I can escape the {{}} so Jira doesn't attempt to interpret it? 

I've tried the normal programming ways to escape, but couldn't find the correct way - if there is one.

I also tried to send HTML code for {} instead of the actual characters ( { and }), but then the external system is not able to interpret these in time - they're rendered correctly as {} in the actual article, but system is not able to look up the variable. 

Arild Hoyland September 4, 2023

I figured this out -- was able to switch the external application to use WYSIWYG/HTML-formatting from creation point onwards - I also used the unicode for { and }, which bypasses Jira smart value lookup (guessing this last one was the real fix).

Thanks for your help!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events