Forums

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

Jira smart values - conditional logic: equals not working as expected

Huynh BKFET August 14, 2023

Dear Jira Community,

I am working with the "equals" statements. But it seems odd that event the string equals "10403", the "equals" statement returns False:

Could you tell me why T_T?

===================================

//Smart Values Logic:

{{#webhookResponse.body.changelog.histories}}
{{items.to}}
{{equals(10403, items.to)}}
{{/}}

====================================

//Output:

XYZ-6604
false
JIRAUSER41800
false
12700
false
10403
false

2 answers

1 accepted

1 vote
Answer accepted
Huynh BKFET August 16, 2023

Finally I'm able to fix it:

{{#if(equals(items.get(0).to, "10403"))}}

1 vote
Evgenii
Community Champion
August 14, 2023

Hi, @Huynh BKFET 

If you're trying to compare integer and string, they won't be equal.

Have you tried including 10403 in quotes? Like:

//Smart Values Logic:

{{#webhookResponse.body.changelog.histories}}
{{items.to}}
{{equals("10403", items.to)}}
{{/}}

Huynh BKFET August 14, 2023

Thanks @Evgenii 

I tried with both double quote and single quote but no success 

Evgenii
Community Champion
August 14, 2023

Then, there is something wrong with value items.to. I checked equals logic, just with raw values, like {{equals("10403", "10403")}}, it returns true

Huynh BKFET August 14, 2023

As you can see, when I output the {{items.to}}, it shows: 10403,which is weird!

Radek Dostál
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 14, 2023

Could there be any whitespace around the value?

Might try a few things off https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields

Such as

{{equals("10403", items.to.trim())}}
{{items.to.equals("10403")}} or {{items.to.equals(10403)}}

 

What about any hidden, non-printable characters.. if you let it print

{{items.to.htmlEncode}}

Anything weird, maybe some unicode control character or something?

Like Huynh BKFET likes this
Evgenii
Community Champion
August 14, 2023

Really weird. 

Maybe whitespaces?

Try to trim value, like this:

{{items.to.trim()}}
Like Huynh BKFET likes this
Huynh BKFET August 15, 2023

@Radek Dostál , the items.to.equals("10403") works as a charm.

though, I am having difficulty wrapping items.to.equals("10403") inside an if statement as follows:


start
{{#webhookResponse.body.changelog.histories}}

{{if(items.to.equals("10403"))}}
{{items.to.equals("10403")}}
-------------
{{/}}
{{/}}
end


it reports an error as follows:


Error rendering smart-values when executing this rule:
Mismatched start/end tags: null != in template-08030e37-4a8c-4512-b43c-edac39cca56e:8: start {{#webhookResponse.body.changelog.histories}} {{if(items.to.equals("10403"))}} {{items.to.equals("10403")}} ------------- {{/}} {{/}} end

Do you have any idea?
amruth.vairamani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 21, 2023

@Huynh BKFET Hello. Were you able to resolve the above? Even for me wrapping equals inside a if doesn't work? If you were able to solve it, please suggest.

Thanks,

Huynh BKFET February 28, 2024

Sorry for late reply @amruth.vairamani , I have fixed this.

{{#webhookResponse.body.changelog}}{{#histories}}{{#if(equals(items.get(0).to, "12700"))}},{{created}}{{/}}{{/}}{{/}}

 

items is a list, so we need to get by index. In this case, we get the first one: items.get(0)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events