Forums

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

Smart Value condition - If statement that i cant get to work

mikael_stiglen May 6, 2025

Hi Guys! 
Hope anyone can help a n00b out :) kinda new to Jira and got a bit stuck. 
This is the statement am trying to get to work. 
{{#if(equals(issue.customfield_10193, "On Site"))}}On distance{{^}}On Site{{/if}}

So what am trying to do is to check whats the value of field issue.customfield_10193, if its one it should return the other. if its ether it should return "On Site". 

This one is created inside an automation where am setting a variable. and then use the variable to set the topic of later created task. its on the task of setting the topic am getting the error. but all am doing there is added the {{Utforas}}.

SB - {{issue.customfield_10073}} - {{Site}} - Q1 - {{Utforas}}

so am pritty sure its the issue with the if-statement where the wrong is. ? ! ? :) 
Thanks 

2 answers

2 accepted

4 votes
Answer accepted
Murat Seven
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.
May 7, 2025

Hi @mikael_stiglen

From what I understand, you want to check the value of issue.customfield_10193, and if it's "On Site", return "On distance" — otherwise, return "On Site".

To achieve this using the equals function in an if condition, you can use the following smart value:

{{#if(equals(issue.customfield_10193.value, "On Site"))}}On distance{{/}}{{#if(not(equals(issue.customfield_10193.value, "On Site")))}}On Site{{/}}

If the answer helps, please accept the answer.

 

Best regards,

Murat Seven

 

 

Darryl Lee
Community Champion
May 7, 2025

Oh, nice @Murat Seven you added .value to the custom field. I missed that.

However I haven't seen {{/if}} to close an {{#if}}. Is that documented anywhere? Maybe it just works because Automation ignores everything after the / in {{}} braces?

Like Murat Seven likes this
Murat Seven
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.
May 7, 2025

I had used {{/}} during testing, but I made a mistake when writing it here.
You're right — I should have written {{/if}} as {{/}}.
I've corrected it now, thank you @Darryl Lee :) 

Like mikael_stiglen likes this
mikael_stiglen May 7, 2025

Gents, :) 
I have tested the: 
{{#if(equals(issue.customfield_10193.value, "På plats"))}}På distans{{/}}{{#if(not(equals(issue.customfield_10193.value, "På plats")))}}På plats{{/}}

And am not getting any errors atleased when saving :D thats a huge step ! 

(its translated to Swedish now instead of english.. just so you know. but its still the same :) On Site and On Distance.)

Thank you ! will test some more <3

1 vote
Answer accepted
Darryl Lee
Community Champion
May 7, 2025

Hello @mikael_stiglen!

Unfortunately Smart Values conditional logic does not support else, so what you probably need to do is have two IFs in a row, like so:

{{#if(equals(issue.customfield_10193.value, "On Site"))}}On distance{{/}}{{#if(not(equals(issue.customfield_10193.value, "On Site")))}}On Site{{/}}

That's all on one line, for readability, here it is:

{{#if(equals(issue.customfield_10193.value, "On Site"))}}On distance{{/}}{{#if(not(equals(issue.customfield_10193.value, "On Site")))}}On Site{{/}}

Although for clarity and simplicity, you might want to do this with an IF/ELSE block:

Screenshot 2025-05-06 at 11.58.59 PM.png

mikael_stiglen May 7, 2025

Thank you @Darryl Lee  for the reply.. :-)
My problem is that i already have an IF statement after my creation of the variable. and am having technical dificulties to make several if`s in the same automation.. but thats problebly my own limit of knowlage that stops that :/ or is that possible to add another if statement before then ? :-O

Jita.jpg

Darryl Lee
Community Champion
May 7, 2025

Hum, my Swedish is a little rusty (hehe), but I'm thinking that a possible problem with multiple IFs (as well as using {{#if}} within Smart variable creation) is that Automation actions execute in parallel (asynchronously). (AUTO-32)

Which means that it's possible {{Site}} is not yet defined by the time you try the Edit action to update Summary to:

 

SB - {{issue.customfield_10073}} - {{Site}} - Q1 - {{Utforas}}

 

(Also, you'll probably want to use {{issue.customfield_10073.value}} there.)

Suggest an answer

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

Atlassian Community Events