Forums

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

Automation not pulling variable from earlier if statement

Wood_ Jeremy
Contributor
December 6, 2025

Hello, i am having some problems with my automation and variables and am looking for some help understanding why this isn't working. 

The first step in my automation is to create the variable. The Variable is set based on a custom field using a series of if else statements. In this picture the custom field was Application, so the variable should be "APP-{{Application name}}" (Atlassian-Test-Jeremy). The if statement works to cerate the variable and then logs that. 

The second step logs several pieces of information from the ticket that will be sent as part of a web request further down the automation.  In this step i try to pull the variable Group Name that was created in step 1, but it comes up blank. 

I tried adding a delay before step 2 and that didn't seem to do anything. 

automation.jpg

 

Before you ask, the 2nd Create Variable seen here is creating a different variable. Its not overwriting the one from step 1. 

2 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 Champions.
December 7, 2025

Hi @Wood_ Jeremy 

Without seeing your entire rule for context...

It appears you are using advanced components as a "container" for the blocks of steps, and creating a variable in the first block and trying to use that variable in the second block.  

First, my understanding is that technique requires adding the variable as an "input" to the later blocks.  Did you add the variable as an input?

Next, I wonder...because the variable is created inside the first block, if it goes out of scope because it longer exists.  You may test that by:

  • Create the variable using the same name after the trigger and before the first block...perhaps with a default value
  • Add a write to the log with the variable after the first block on the main processing path
  • If it contains what you expect, scoping was the problem

 

Kind regards,
Bill

Wood_ Jeremy
Contributor
December 8, 2025

Photo provided in reply to Tomislav.

I'm not using advanced components so i don't believe that should be the cause. 

Unless each if-else string acts as its own block? that's what I'm confused about. I cant find anything documented saying that it does act on it own. But i also cant find anything saying it doesn't either.......

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 Champions.
December 8, 2025

Thanks for that information, @Wood_ Jeremy 

I just re-tested without advanced components, and with an IF / ELSE block, I would expect the variables to work later...after setting them in an earlier block.

Would you please post an image where the GroupName variable is created?

And, you do not also have a work item field by that name, do you?

Like # people like this
Wood_ Jeremy
Contributor
December 9, 2025

Hi Bill. 

Please see the image i replied to Tomislav Tobijas with. It shows the full automation. 
https://community.atlassian.com/forums/image/serverpage/image-id/417484i99D4C87E9ADC0DE9/image-size/large?v=v2&px=999 

 

I do not have another work item field with the same name. When i save the variable to my log during step 1 it shows up correctly.  But when i got to write the same variable in step 2 it shows blank. 

Gideon Nolte _Eficode_
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 Champions.
December 11, 2025

Hi @Wood_ Jeremy

I can confirm @Bill Sheboy suspicion. I ran a little test with the variable created in the root cause and without it.

 

You setup:

  • Trigger
  • If
    • Create variable: GroupName
  • Else
    • Create variable:  GroupName
  • If
    • Use variable:  GroupName
  • Else 
    • Use variable:  GroupName

-> The variable is not available within the second if/else section

Working setup:

  • Trigger
  • Create variable: GroupName
  • If
    • Create variable: GroupName
  • Else
    • Create variable: GroupName
  • If
    • Use variable: GroupName
  • Else 
    • Use variable: GroupName

-> The variable is available within the second if/else section

 

See the screenshots for reference.

Bildschirmfoto_11-12-2025_123648_demo-gideon.atlassian.net.jpegaudit_log_var_scoping.png 

Best regards

Gideon from Eficode

1 vote
Tomislav Tobijas
Community Champion
December 7, 2025

Hey @Wood_ Jeremy ,

Can you maybe share screenshots of rule actions and exactly what you're logging (smart values)? This might help a bit to debug this. 👀

In general, variables should be available throughout the entire scope of the automation rule, meaning these aren't, let's say, limited to a specific (sub)set of blocks, and therefore it should work.
There's just an exception for branches: if you create a variable inside a branch, it is only available within that branch and not outside of it.

Cheers,
Tobi

Wood_ Jeremy
Contributor
December 8, 2025

Here is the automation rule slimmed down. In the full version there are a couple more else if statements during the 1st part but that's really the only main difference. 

Don't mind the Deleted field notations. I exported my automation to a different space and took this photo before also moving over the custom fields. 

automation.jpg

Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events