Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Use result of match function in smart value branching / for each loop

I have an automation rule in which I:

  • Make a web request
  • Execute `match` to extract multiple occurrences of a pattern from the response
  • Branch-iterate over the occurrences to do something else (e.g. use the matched substring in a JQL query)

Screenshot 2022-04-28 at 13.43.44.png

The problem is the "for each: smart value" branching doesn't actually iterate over the matches but instead treats the result of `match` as a single value.

Screenshot 2022-04-28 at 13.48.33.png

Does anyone know how I could loop over the matches one by one?

3 answers

1 accepted

2 votes
Answer accepted

As mentioned in my reply above, the audit log smartly collapses log messages which creates the impression that the whole list is a single string. It is, in fact, not though which means you can use operate on the element inside the branch exactly like you'd expect.

Screenshot 2022-04-28 at 21.56.18.png

Thanks everyone for the quick help! This is a great community.

Hi @johannesm 

I find that advanced branching occasionally needs "help"; sometimes it parses the source as a list and sometimes not.  Two approaches for your source list are:

  • save the match() result in a created variable (which forces to text), and feed that into the advanced branch using split(",")
  • Or, immediately iterate on the match result in the advanced branch source, forcing it to a list explicitly.  For example:

And also...I highly encourage you to always make variable names (created or branch) different from all possible reserved words.  In your advanced branch you call it match and I would suggest always prefixing, such as varMatch.

Kind regards,

Filipi Lima Atlassian Team Apr 28, 2022

Thanks for the master class, @Bill Sheboy !

First of all, thanks for pointing out that creating a variable forces to text. I was not aware and that explains some failures I saw while testing other things.

I tried both your suggestions but the behavior wasn't any different. One thing I did notice during testing though is that the audit log appears to smartly collapse log messages.

When I used


I noticed the angular brackets being added to each element in the output.

Screenshot 2022-04-28 at 21.48.47.png

So ultimately, the audit log just makes it seem as if the value is a single string by collapsing the log messages into a single line.

Which means it worked correctly from the start and I just didn't realize because the log output kept me from trying to proceed. 🤦‍♂️

Like # people like this
Filipi Lima Atlassian Team Apr 28, 2022

We've all been there.. I confess I missed it completely, too.

Regardless, I'm glad to hear it's working!

1 vote
Filipi Lima Atlassian Team Apr 28, 2022

Hello! Welcome to the community!

One thing worth trying is figuring out whether the output of your regex is a list or a string - if it was a list I would expect it to work on your setup so let's check.

To do that, try logging one of these on the audit log:



Taken from:

If your match variable is a string, we'll probably get an error on the above and you'll need to .split your regex output to create a list.

Look for the .split function here:

Let us know the output of the audit log tests.

Thanks for your help Filipi!

It seems like the output of calling `match` is a list because calling `first` on it gives the first element.

However, inside the for each branching I appear to get the whole list as a single string and calling `first` there does nothing.

Screenshot 2022-04-28 at 15.23.41.png

Mykenna Cepek Community Leader Apr 28, 2022

Now that you know it's a list, you can iterate on the list as a Smart Value (not in a branch). I'm not sure if that will achieve your goals, but a lot of list processing can be done with Smart Value notation. See the Combined function examples.

For more complex handling in Smart Value lists, check out the conditionals you can use while iterating on a list.

Note that all these will do some processing of the list, resulting in some text that you would use elsewhere (e.g. in an email, or to set a variable). You don't actually get to manipulate the list.

Like johannesm likes this

Thanks Mykenna! This made me realize that I could "unroll" the branch-loop and instead manually access list elements by index. This ends up with a quite lengthy automation rule but at least works if you know a reasonable finite upper limit for the length of the list.

Screenshot 2022-04-28 at 21.31.44.png

Like Mykenna Cepek likes this

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you