Need help in Jira Automation if/else Smart value

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 4, 2024

Hi Guys, 

Need your help in setting up one automation rule. 

I have three dropdown field A, B and C and one Number field D. 

All three dropdown field have options Yes and No 
If A field value is Yes and B,C value is No then automation should set value of D to 1
If A field value is Yes and B is Yes and C is No, then Automation should set value of D to 2 

Yes = 1 

No = 0 

Kindly help me with smart expression. 
I have tested this : 

{{#if(equals(issue.customfield_10321.value,issue.customfield_10322.value,issue.customfield_10323.value))}}3{{/}}

But it's not working. 

 

Kindly suggest. What would be correct expression or what would be best approach to setup this automation. 
There are 8 combinations. 

3 answers

1 accepted

1 vote
Answer accepted
Max - Swift Checklist Dev
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.
October 4, 2024

Hi @Vikrant Yadav ,

 

you can create a variable where you simply concatenate all dropdown values and then write if conditions to compare the variable with conditions like "000", "001", "010" etc.

 

Screenshot 2024-10-04 at 20.30.53.png

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 4, 2024

Hi @Max - Swift Checklist Dev  Thanks for your response!

This automation rule is easier to implement. Let me give it a try. I can use single variable for all single select list field.

 

 

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 5, 2024

Hi @Max - Swift Checklist Dev  Thanks a lot for your help!

I created a flow using variable and it's working fine.
We can apply two condition without separating a two condition using space or comma ? 

 

{{#if(equals(fieldValues, "YesYesYes"))}}3{{/}}
{{#if(equals(fieldValues, "YesYesNo"))}}2{{/}}

Screenshot 2024-10-05 at 12.42.33.pngScreenshot 2024-10-05 at 12.43.01.png


Max - Swift Checklist Dev
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.
October 5, 2024

Hi @Vikrant Yadav ,

I didn't quite understand your question. Could you please provide more details?

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.
October 4, 2024

Hi @Vikrant Yadav 

First thing, as you appear to have multiple values to test, I recommend using a Lookup Table where the row keys are the concatenated values of the three fields and the row values are the desired value of field D.  For example, a row could be key= YesYesNo with a value= 2.  Or better still, the key could be explicit: key= A:Yes, B:Yes, C:No

Or, create a Karnaugh map to identify and reduce the number of cases from 8, when possible.

Regardless of those ideas...

 

What are the types of your A, B, and C fields: single-select option, or something else?

 

Which format of conditional are you trying to use as what you show matches neither of these:

{{#if(some condition)}}value when True{{/}}

{{if(some condition, value when True, value when False)}}

 

Kind regards,
Bill

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 5, 2024

Hi @Bill Sheboy  Thanks for your help!

I never created a lookup table.

For Key do I need to use Smart value ( {{issue.customfield_10321}} ) to get single select field value or i put YesYesNo and value 2 , Key : YesYesYes and Value 3 

and then apply a condition. In Condition, I need to get custom fields value.  

What would be the condition when all value are Yes ? 

 

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.
October 5, 2024

You would either need to use the and() function to combine values or concatenate them, as I noted with the lookup tables.  (One advantage of the lookup table is ease of maintenance for this scenario's complexity.)

To use the lookup table approach, list each of the combinations needed, and then test the result with get() on the concatenated values. For example, with some made up values:

  • action: create table
    • name: tblDecodeValues
      • row
        • key: NoNoNo
        • value: apple
      • row
        • key: NoNoYes
        • value: 100
      • ...
      • row
        • key: YesYesYes
        • value: blue
  • to return the value, use a variable get() function
    • first concatenate the values in a variable:
      • name: varConcatValues
      • smart value: {{issue.customfieldA}}{{issue.customfieldB}}{{issue.customfieldC}}
    • then lookup with get()
      • {{tblDecodeValues.get(varConcatValues)}}

 

 

To use the and() function instead, two would be needed to create the test, as there is a limitation where the function only works with two values.

{{#if(and(first condition, and(second condition, third condition)))}}value when True{{/}}

 

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 4, 2024

Hello @Vikrant Yadav 

Is there a reason you are not using the IF or ELSE condition construct for this in your Automation rule?

Screenshot 2024-10-04 at 10.23.14 AM.png

With that construct you can use multiple Smart Value conditions at once, using the AND or OR logical evaluator across them:

If A field value is Yes and B,C value is No

... then use an Edit Issue action to set the field

Then add Else-if for the next combination, and so on for each combination.

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 4, 2024

Hi @Trudy Claspill  Yeah, I can use simple if/else but combination of If/else is 32 in my case. Means 31 else statement i need to add in automation. It will become very long automation, that's why i an thinking to do it via smartvalue if/esle

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events