Forums

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

Jira smart values - conditional logic

Jérôme RAVIER November 16, 2022

I have a ticket with the customfield_10448 set to: Production

And then an automation rule having an action trying to set another field depending on the comparison of this field's value with a string:

    Environment : {{issue.customfield_10448.value}}
    {{#if(equals(issue.customfield_10448.value, "Production"))}}
    MEP
    {{/}}

Can someone explain me why this code only output that:

    Environment : Production

and not this:

  Environment : Production

  MEP

???

Of course, a hint at how to fix it will be much appreciated!

2 answers

0 votes
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.
November 16, 2022

Hi @Jérôme RAVIER 

Some things to check for this symptom would be:

  1. What is the type/source of your custom field?  For example, is it a single-select field, with a drop-down...or perhaps a calculated field from an addon app?  If it is calculated that might explain what you are seeing as some values do not evaluate inside of conditional logic (or smart value, list filtering, etc.).
  2. If the field is single-select, have you checked your custom field setup to confirm there are no leading/trailing spaces around the values, such as "Production"?  The extra spacing could cause the first one to fail and the created variable to perhaps drop them during the conversion to text-type, and so succeed.
  3. In your smart value expression, are those double-quotes exactly what you show, or the slanted/curly ones?  The latter won't work in smart values.
  4. If all of those are okay...you do no show your entire rule for context.  Perhaps there is something else in the rule components (i.e. trigger, action, condition, branch) around your usage of that smart value expression which leads to this behavior.  Showing the rest of your rule might provide context.

Kind regards,
Bill

0 votes
Jérôme RAVIER November 16, 2022

Well, I went around by using a "Create variable" action, naming it envSV and assigning it {{issue.customfield_10448.value}}.

Then the modified code worked:

    {{#if(equals(envSV, "Production"))}}
    MEP
    {{/}}

Output : MEP

Looks like some review of Jira smart values for conditional logic should be done by developers.

And I'm not talking only about the poor documentation...

Jérôme RAVIER November 16, 2022

And of course, as it's only a workaround, I can't deem this answer acceptable ;-)

Jack Brickey
Community Champion
November 16, 2022

Hi @Jérôme RAVIER ,

is it required to use the advanced (json) here? Can you not just use the If/else condition?

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