Skip to main content

This has been discussed ad nauseum in countless threads, but I cannot for the life of me find how to correctly provision the workflow to iterate through the collection.

 

Let's say I have a repeating section with a single text field that a user can add to.

21492i552CDEE4B3E77F48.png

The xml will look like this, in my RepeatingSection column (plain text, multiline):


<?xml version="1.0" encoding="utf-8"?>

<RepeaterData><Version />

<Items>

<Item><Thing type="System.String">First thing</Thing></Item>

<Item><Thing type="System.String">Second thing</Thing></Item>

<Item><Thing type="System.String">Third thing</Thing></Item>

</Items>

</RepeaterData>

 

I know I need to use Query XML to get the collection information, but I don't know how to set it up correctly. I can drill down to the "Thing" item that I want, but do I keep the e1] as the index when initially querying? If I set it to a WF variable, it doesn't work.

21493iE5E852428976629A.png

Here are my variables:

21494iAA91009F8291628E.png

My For each loop performs a Collection operation to Get items from the collection (at least that's the idea)

21495iAE0A4267D6D20B49.png

Here is the For each:

21496i875F325084D87B4F.png

And the Collection operation:

21497iF77797F8BD261F4E.png

Which should update another plain multiline with the Thing(s) texts:

21498i8DEC7CCD2AC27170.png

Except it only grabs the first item, which is "First thing" and helpfully logs: "Index 0 has thing First thing" which is correct but not exactly what I want. 


Why is it not looping through the collection?

hey @MikeCrawford ,



 



I would set it to: //Items/Item/Thing



 



rest of ur workflow looks fine.



 





 


Hey thanks @Aleximo ! Turns out it was as easy as identifying the //Item, since that's the only thing in the node. For "real" items with more fields, your suggestion will work perfectly. Thanks!





The For loop and Collection operation were configured correctly.



 



My biggest trouble is finding good, pertinent examples on this Community site. I wish the documentation had some examples.


Reply