Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,734
Community Members
 
Community Events
176
Community Groups

Why OR returns wrong value?

Hello, community.
I found some weird stuff going on with OR smart value. For some reason {{or(true, false)}} returns 'false' instead of 'true'.

Given:

{{issue.fixVersions.name}} --> May2022 
{{issue.fixVersions.name.equals("May2022")}} --> true

{{exists(issue.fixVersions.name)}} --> true
{{not(exists(issue.fixVersions.name))}} --> false

This to be expected, so far so good.
The weird stuff begins when I try to combine some of this expressions with OR smart value:

{{or(issue.fixVersions.name.equals("May2022"), not(exists(issue.fixVersions.name)))}} --> false

WTF? Equals returns 'true', NOT returns 'false'. Why OR returns 'false'? What I'm doing wrong?

I did some further tests, and that's what I get

{{or(issue.fixVersions.name.equals("May2022"), false)}} --> false

{{or(true, not(exists(issue.fixVersions.name)))}} --> true 

So, the problem lies somewhere in 'issue.fixVersions.name.equals("May2022")' expression.

I tested the same expression with Summary field, and it works as expected

{{issue.summary}} --> TEST
{{issue.summary.equals("TEST")}} --> true

{{exists(issue.summary)}} --> true
{{not(exists(issue.summary))}} --> false

{{or(issue.summary.equals("TEST"), not(exists(issue.summary)))}} --> true

So, there must be something with fixVersions field, that I don't get.

I did more test, and it broke my mind completely

{{or(issue.fixVersions.name.equals("May2022"), false)}} --> false
{{issue.fixVersions.name.equals("May2022")|false}} --> true

{{or(true, not(exists(issue.fixVersions.name)))}} --> true
{{true|not(exists(issue.fixVersions.name))}} --> false

 Once again, WTF? Shouldn't this expressions return same results?

1 answer

0 votes

Hi @axone 

That seems interesting...

Some of the conditional functions return true/false and some return true/null: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

Add to that fixVersions is a list and you do not appear to be accessing a specific list element and I wonder if the object is sometimes trying to parse rather than always resolving to one entry.

Even though it appears your fixVersions only has one value, perhaps try focusing the expression before conditional testing, with {{issue.fixVersions.first.name}}

Kind regards,
Bill

Yes, .first does help.

But still, the behavior of this conditions seems unpredictable. Simple .exists, .equals, not() statements work somehow, they clearly parse fixVersions list somehow and return values as I expected them to. But not or() function for whatever reason.

Like Bill Sheboy likes this

Agreed, and...

One opportunity for improvement of Automation for Jira is documentation.  For example, smart values should clearly indicate which default attribute is used when they are not fully de-referenced, especially for lists.  Sometimes it appears to be {{issue.someField.id}} and other times it is {{issue.someField.name}} and sometimes it is just null when no attribute was selected.  There may be a standard...it is not effectively communicated to users.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events