Forums

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

How to use custom Variables in conditional logic

Vitali Fedarau September 14, 2022

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

Suggest an answer

Log in or Sign up to answer
0 votes
Stefan Salzl
Community Champion
September 14, 2022

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

Vitali Fedarau September 18, 2022

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?

Diane Fahr January 29, 2024

I have tried your example and it does not work. I set a variable to either 1 or 0 and have this ..

on creation {{var}} = 0

if statement {{var}} is set to 1

after the if statement confirm {{var}} = 1

then {{#if(var.asNumber.gt(0))}}test{{/}}

nothing returns ..

thoughts on what i am doing wrong?

TAGS
AUG Leaders

Atlassian Community Events