Forums

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

Help with For each: Smart value. not able to actually parse the list

CJ Edwards
Contributor
February 23, 2023

Hi all!

I have an interesting problem trying to get the Advanced Branching working for my automation.  I cannot seems to get the list to iterate in a For Each in the advanced branch.

sorry this is big.. I hope it is well enough formatted to make sense!

Thanks for any assistance :D

The goal,

- Capture confluence pages linked to the Issue

- gather the version and title of each page

- Comment on each of the pages

Notes of import,

This automation works 100% for issues with only "1" linked confluence page


 

The attempt

- Pages are gathered via REST .../rest/api/3/issue/{{issue.key}}/remotelink

- page id's gathered via variable

{{confluencePageIds}} set from {{webResponse.body.globalId.substringAfterLast("=")}}

- log action. shows example. 322437121, 322568215, 322797582, 322830349, 328171578

- For each: Smart value, {{singlePage}} result one single iteration

-- problem starts here --

- log action inside the For each: example. 

single page -> 322437121, 322568215, 322797582, 322830349, 328171578

this wont work as the next REST calls for getting the page title incorrectly as:

.atlassian.net/wiki/rest/api/content/322437121, 322568215, 322797582, 322830349, 328171578?expand=version

 

- Expected result ---

- log action inside the For each: example. 

single page -> 322437121

 ....atlassian.net/wiki/rest/api/content/322437121?expand=version

single page -> 322568215

 ....atlassian.net/wiki/rest/api/content/322568215?expand=version

single page -> 322797582

 ....atlassian.net/wiki/rest/api/content/322797582?expand=version

single page -> 322830349

 ....atlassian.net/wiki/rest/api/content/322830349?expand=version

single page -> 328171578

 ....atlassian.net/wiki/rest/api/content/32811578?expand=version

Then I can continue to grab version and other things I need, to complete before the final POST to comment on each of the pages.

 

What I have done to try to fix

- Create a second variable through splitting the first

{{confluenceList}} set from  {{confluencePageIds.split(",")}}

compare the log result, and get exactly the same list

split list 322437121, 322568215, 322797582, 322830349, 328171578 vs 322437121, 322568215, 322797582, 322830349, 328171578

 - Check size of List

Log action {{confluenceList.size}} and {{confluencePageIds.size}} both result in empty/null

My guesswork:

- Capturing the data from {{webResponse.body.globalId.substringAfterLast("=")}} is a String not a list?

- splitting the above does not create a New List with {{confluencePageIds.split(",")}}

Screenshots
image.pngimage.pngimage.pngimage.pngimage.pngimage.png

1 answer

1 accepted

1 vote
Answer accepted
CJ Edwards
Contributor
March 2, 2023

The Answer !!
Thanks to @Marcelo Beloni for helping out on this one.

The For Each: smart value needed to be split there and not before, trim() was also required to stop errors

The final solution in this case it needed to be {{confluencePageIds.split(",").trim()}}

image.png

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