Forums

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

Automation using JSON IF/Then

Jesper
Contributor
July 29, 2025

Hi,

I'm trying to make an automation, that when a Epic is created it will make some tasks for it.
These are made from various custom fields in the epic. 

Some of the tasks are not needed in all scenarios, this is determined by a custom field.
E.g. if custom field is X, then set status to Done otherwise leave it.

I have tried making an IF/Then statement in the JSON of these tasks.
But I can't for the life of me get it to work.
The custom field is a drop-down menu, where the user can select a single value - these are strings.

I have tried using quotation marks around the value, I have also tried to remove them - and I end up with the same result.
Here is an example, where I just make an audit log to verify the value.

{{if(equals(issue.custom field.value, "X"), "41", "21") }}

If I have quotation marks around X, I always get 21 - if not always 41. And it doesn't matter if the value of the custom field is X or not.

I have even tried using the default fields, e.g. summary - similar experience.

What am I doing wrong?
Or is there a better method?

3 answers

1 vote
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.
July 29, 2025

Hi @Jesper 

You definitely can test a single-selection option, custom field's value as you show.  The key is having the correct field...

Smart values are name, spacing, and case-sensitive, and they often do not match the field name displayed on the work item views.  When an incorrect one is used, that interprets as null, and often fails silently.  And in some cases, automation rules cannot use the named-smart value, and instead must use the custom field ID.

 

I recommend pausing and using an example work item with this how-to article to identify the correct smart value and custom field ID for your field:

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Once found, please update your conditional expression and re-test.

I also recommend writing the value directly to the audit log to confirm the value is what you expected.

 

Kind regards,
Bill

0 votes
Marc - Devoteam
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.
July 29, 2025

Hi @Jesper 

Using a single select option, the values are not strings.

But the values have an id, and as mentioned by @Kris Dewachter use the correct smart value for this.

So you can make a condition based on {{issue.custom field.value}} equals "value name"

 

Jesper
Contributor
July 29, 2025

Hi,

Thank you for the answer.

Just so I understand, in the single select option, if I have options like - US, AU, BOB.
I can't use these values to check against? 
I have to find the ID Jira/Atlassian gave these values?

Sorry for asking, but how do I even find these IDs?

Very surprised that I have to use the ID and can't use the display name (or what I thought was the value).

0 votes
Kris Dewachter
Community Champion
July 29, 2025

Hi @Jesper ,

What type of custom field is it ?

What is the actual value of "issue.custom field.value" when you display in it in the automation log ?

Can you try putting the value in a "variable" first, and then perform a check on the variable?

Best regards,

Kris

Jesper
Contributor
July 29, 2025

Hi,

Thank you for  your reply.
I will answer one by one.

  • What type of custom field is it ?
    • It's a single select option

  • What is the actual value of "issue.custom field.value" when you display in it in the automation log ?
    • What I have set it to in the given Epic, could be US or AU, etc.
      All the available values in the single select are 2 to 3 letters.

  • Can you try putting the value in a "variable" first, and then perform a check on the variable?
    • Sure, and this gives the same outcome as using the custom field directly
Kris Dewachter
Community Champion
July 29, 2025

Hi @Jesper ,

I did a quick check creating my own custom field.

Created a "single select list" field called "Country". Options are "US" and "AU".

When I use the "Log action" in the automation rule, the selected value on this issue is displayed correctly. 

Ex. {{issue.Country.value}} results in "US".

When I use the following if statement in a "Log Action", i also get the correct result and behaviour.

{{if(equals(issue.Country.value, "US"), "41", "21")}}

When US is selected, 41 is returned. When AU is selected, 21 is returned.

Can you try this in your automation rule and check the behaviour.

You also mentioned you are trying this in the JSON. Am i correct in assuming you are building a JSON in the "Edit work item" action in the automation rule? How does that look exactly ?

br,

Kris

 

 

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