Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Variable set in if else-if ends up null

Hi, I am trying to set due dates based on the Component that is set on the Story (Small, Medium, Large).  Note that I copy the Components to the sub-tasks in an attempt to simplify the logic of looking up the Components.  

I created an if else-if branch to manage these three conditions, and in each I set a variable to hold the date.

Right after the variable is set, I have a For Parent branch to create sub-tasks and assign due dates...but they are turning up blank.

So I added a test audit log entry to see if the variable existed even just after the if else-if branch ended and it doesn't.  It's already null.

I can see in the rule audit log that the condition passes successfully so why is my variable null?

thanks

 

rule1snip.PNGrule2snip.PNGrule3snip.PNG

 

1 answer

1 accepted

3 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 13, 2023

Is the log action within the if/else block or outside? The screenshots indicate that it is outside of the if/else block and that would explain why the variable is null. A smart value that is created with a if/else block is only available within that block and cannot be accessed outside of it.

Outside.  The article where they launched this feature says exactly this:

This article is for the power users of Jira automation to show you how to use our new 'Create variable' action. 

This new action allows you to define your own smart value, which can be used in other actions and conditions in the same rule. 

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Create-variable-New-component/ba-p/1448118

 

So to me it makes no sense that it is confined to only the if else block.  Maybe they'll broaden in the future.

Like Walter Lamm likes this
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 13, 2023

It depends on where you create the variable. If you look in the article they are creating the variable first before using it in the branch. If the variable is created with the branch, you will not be able to access it outside of that branch, that's the difference.

I agree with Derek here. I have a similar automation where I set a variable, and need to use outside the IF block I created it in. 

I also found this: https://jira.atlassian.com/browse/AUTO-154

 

Looks like it's an active feature request.

Like Walter Lamm likes this

@Mikael Sandberg yes you're right -- but the value of the variable is based on which Component is tagged so I have no choice but to set it in an if/else block.  

Kelly Arrey
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.
Feb 14, 2023

I haven't tried this but can you create it outside the if/else block and then set in inside?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 14, 2023

@Kelly Arrey yes, if you create the variable outside of the if/else block it becomes a global variable and can then be used inside the if/else block. Have a look at the article above that Derek linked to.

Like Kelly Arrey likes this
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 14, 2023

@Derek F You can set the variable to null outside of the if/else block and then use it within to set it to the right value.

Like # people like this

I reread that a few times so...I use "create a variable" to create it before the loop and then "create a variable" again to set it to the actual value I want and use it?  

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 15, 2023

Correct, you will have to use the create a variable multiple times, but as long as you use the same name it will just update the value for the variable.

Like Steffen Opel _Utoolity_ likes this

Dang, I just created the a gross workaround for this (but it works).  When I'm feeling brave I'll optimize it.  Thank you

Like Kelly Arrey likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events