MikeCrawford
Scholar

Query XML for Repeating Section - how to set up correctly?

Jump to solution

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.

MikeCrawford_0-1643067675969.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 [1] as the index when initially querying? If I set it to a WF variable, it doesn't work.

MikeCrawford_1-1643067959883.png

Here are my variables:

MikeCrawford_2-1643068076072.png

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

MikeCrawford_3-1643068184139.png

Here is the For each:

MikeCrawford_4-1643068214230.png

And the Collection operation:

MikeCrawford_5-1643068241601.png

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

MikeCrawford_6-1643068299738.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?

0 Kudos
Reply
2 Replies
Aleximo
Contributor

Re: Query XML for Repeating Section - how to set up correctly?

Jump to solution

hey @MikeCrawford ,

 

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

 

rest of ur workflow looks fine.

 

Aleximo_0-1643100676036.png

 

0 Kudos
Reply
MikeCrawford
Scholar

Re: Query XML for Repeating Section - how to set up correctly?

Jump to solution

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!

MikeCrawford_0-1643161337461.png

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