Hi all,
I'm using advanced branching in Cloud Automation, to setup a variable which I use later on, outside of the branch.
But apparently the variable exists only within the scope of the branch, and is null when the code exits the branch.
Example:
- In my Automation, I create an advanced branching by splitting the issue summary with separator ","
- If I find the text "example" inside the branch, I create variable "found", with value "true"
- Outside of the branch, I put a conditional statement: if {{found}} = true
- apparently, this statement is always false, and the variable {{found}} is unset
EDIT: forgot to mention that right now the only workaround I found for this problem, is to add a special label to the issue when I find "example", and re-fetch its data. So, outside of the branch, I just look for that label instead.
Could anyone confirm that this is the expected behaviour?
Thanks
Hi @Fede B.
Yes, that is the expected behavior.
Branches which could be on more than one thing / issue are run in parallel and asynchronously, and so any variable created inside the branch is gone by the end. And...there is no guarantee when such branches will complete, up until the last step of the rule. Thus you could not check such results after the branch (in the rule logic) as the branch is likely still executing.
A workaround for the scenario you describe is to use the text function match(): https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--
For example, test the result of this:
{{issue.summary.match("(example)")}}
Please see the details of regular expressions to adjust for your needs.
Kind regards,
Bill
Hi @Bill Sheboy ,
Thank for your answer.
Yes, in my example the match() function would work, but in reality the automation I'm building is much more complex than that, and using match() results in a lot of work with smart variables and related frustration :-)
It would be nice to have a functionality for branching similar to that of web requests: a checkbox, to make sure that all branch code is processed before continuing to process the rest of the automation. I'm not sure if there's already a ticket to request this feature, I think it's something worth to be voted.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are several open suggestions to add that option for branching, such as this one: https://jira.atlassian.com/browse/AUTO-32
Although due to the potential to make longer running rules exceed the service limits, it might then halt all rule executions!
If you want additional help with alternatives for your more complex rule, for which match() may not be a good fit, please describe the problem you are trying to solve and post images of your complete rule and audit log details, and describe what does not work as expected. Those will provide context for the community to offer more suggestions. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.