Why OR returns wrong value?
Asked by axone:

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?


Answers:
author: Bill Sheboy
body: Hi [@axone](/t5/user/viewprofilepage/user-id/4857586)

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

comments: author: axone
body: 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.


author: Bill Sheboy
body: 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.