Uploaded image for project: 'Automation for Jira Server'
  1. Automation for Jira Server
  2. JIRAAUTOSERVER-1010

Variables created within a branch are only available outside of it if another variable has been created beforehand

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Low Low
    • None
    • 9.0.3, 9.1.1
    • Actions
    • None
    • Severity 3 - Minor

      Issue Summary

      When using the "Create variable" action within a branch, you'll usually be unable to access the stored value outside the branch.

      However, if you create a different variable before branching the rule, and then create the variable inside the branch, you will be able to access the variable created inside the branch outside of it.

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Create an automation rule.
      2. Branch into another issue.
      3. Create a variable inside this branch.
      4. Try using the variable outside the branch.
      5. The value will be blank.

      Expected Results

      A4J should be able to access the data from variables created inside branches.

      Actual Results

      A4J is only able to access the data from variables created inside branches if another variable was created beforehand in the main execution path.

      Workaround

      Since the data from variables will be available outside their creation branch if another variable exists beforehand, we can create a variable before branching the rule, and ignore its value.

      1. Create an automation rule.
      2. Create a variable with any value on it.
      3. Branch into another issue.
      4. Create a variable inside this branch.
      5. Try using the variable outside the branch.
      6. The value will be available.

            [JIRAAUTOSERVER-1010] Variables created within a branch are only available outside of it if another variable has been created beforehand

            A variable inside a branch or if/else block is by design not accessible outside of it. It is treated as a local variable in the context of the branch or if/else block. 
            The feature request to change this behaviour: https://jira.atlassian.com/browse/JIRAAUTOSERVER-985

            Anna Przybycień added a comment - A variable inside a branch or if/else block is by design not accessible outside of it. It is treated as a local variable in the context of the branch or if/else block.  The feature request to change this behaviour: https://jira.atlassian.com/browse/JIRAAUTOSERVER-985

            Greetings!

            My understanding is this work-around / trick only works on branches which are on one-and-only-one issue, as they are essentially converted to run inline.

            All other branch types which could be on more than one issue / thing are run in parallel and asynchronously.  My understanding is they are in separate processing threads do not share the context with the main rule path, and so could not make changes to a variable created earlier AND have that persist outside of the branch.  (Which would not be helpful anyway, as there is no guarantee of when the branch will complete, up until the last rule step.)

            Kind regards,
            Bill

            Bill Sheboy added a comment - Greetings! My understanding is this work-around / trick only works on branches which are on one-and-only-one issue , as they are essentially converted to run inline. All other branch types which could be on more than one issue / thing are run in parallel and asynchronously.  My understanding is they are in separate processing threads do not share the context with the main rule path, and so could not make changes to a variable created earlier AND have that persist outside of the branch.  (Which would not be helpful anyway, as there is no guarantee of when the branch will complete, up until the last rule step.) Kind regards, Bill

              Unassigned Unassigned
              abrancalhao@atlassian.com Armando Neto
              Affected customers:
              0 This affects my team
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: