Forums

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

Jira automation, For each Smart Value not working as expected

Tiele Declercq August 25, 2023

Hi,

My smart value: smart value: {{webResponses.body.body.view.value.match("<tr><th[^\>]*><p><strong>Application Administrator</strong></p></th><td[^\>]*><p>(.+?)</p></td></tr>").match("<a .+?data-account-id=\"(.+?)\".+?>.+?</a>")}}

Returns a list of 3 user id's in logging formatted as: [xxx, yyy, zzz]

When I add Advanced branching, with this smart value I would expect that it fires 3 times but it does not. It fires once and shows [~accountid:5cf5014468fe490f20938072, 5af545395f0d5b06c28a8a76, 5f8d5e48606d40006928bcbd]

How can I loop through this list and perform actions with each of these items?

2 answers

1 accepted

1 vote
Answer accepted
Tiele Declercq August 28, 2023
{{myVar.first}}
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 Leaders.
August 25, 2023

Hi @Tiele Declercq 

That match() function result is an array, rather than a list.

So the work-around when this happens is to strip off the square brackets with chained, remove() function calls, followed by a split() to create a list.  Storing your original parsing into a created variable can help with this.

{{yourCreatedVariable.remove("[").remove("]").remove(" ").split(",")}}

Kind regards,
Bill

Tiele Declercq August 28, 2023

Bill, thank you for the tip as you were partially on to something.

When I do

{{myVar.count}}

It showed only 1 item. However..

{{myVar.first.count}}

Did the trick and gave me 3 results. So I was getting a nested list back from the match function and had to use the first item to loop through.  

Like Bill Sheboy likes this
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 Leaders.
August 28, 2023

To help diagnose things like this in the future, I recommend first writing the entire web response to the audit log.  And then as you drill down you can write more expressions to the log to observe you are getting what is expected.

Suggest an answer

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

Atlassian Community Events