Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,622
Community Members
 
Community Events
168
Community Groups

How to use custom Variables in conditional logic

I need to use custom variables in conditional logic,

for example,

I create a variable called "Size" and make it "2"

Then I want to have next check: 

{{ #if(Size.gt(0))}}
Do something good
{{ /}}

Nevertheless, it doesnt seem to work at all, does it mean that current conditional logic do not support the custom variables? Or am I doing something wrong

1 answer

Hi @Vitali Fedarau and welcome to the community,

as far as I know variables are stored as string. Using ".asNumber"-method should solve the problem. See the documentation below:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#asNumber

 

I tested the following in my environment successfully (testNumber is my variable and set to 5):

{{#if(testNumber.asNumber.gt(4))}} test {{/}}

 

Best
Stefan

Hey, @Stefan Salzl thanks a lot for your answer!

Unfortunately, I have tried it already and it doesn't work in a more complicated logic,

Step by step:

My flow is next Screenshot 2022-09-18 at 19.33.33.png

The reason why I have Look up + 2 variables creation, because I need multiple Lookups.

What I have for Variables creation, One: Screenshot 2022-09-18 at 19.34.28.png

And OneSize: Screenshot 2022-09-18 at 19.35.02.png

And Slack Message I need to compile:

Screenshot 2022-09-18 at 19.36.09.png

So what I am doing here, I am creating 3 Lookups (you can see only One lookup+variables as I removed the rest for 1 specific showcase), after that I need to check the size of the lookup, if there is no issues within a specific epic link, then if condition should not run and the tickets + epic link summary should not show on the slack report.

So, I am building the One variable as the result of lookup formatting (which actually magically works), and building variable OneSize as size of the array (in my case it is 2, I have tested it). I have tried the asNumber stuff, but unfortunately, no matter what I do, this checkup gt(10) doesnt work. Each time it adds the section to the report, even number of tickets definitely lower than 10 (2<10 I believe). 

So maybe even with just saving integer as 2 it works, with saving the lookup size it doesn't seem to work. Am I loosing some other magic here?

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events