Query a list for multiple items, each item with repeater


Badge +8

Let's see if I can even explain myself correctly. I'm trying to query a list, returning multiple items. Each item has a repeater with multiple details.

Item has:

Building

City

Repeater

Created Date

Repeater fields are:

      Person

      Number

Since I have multiple items I'm returning, I need to call web service. I'm able to build an HTML table with the returned information that is stored in the Results variable (After using XSL transform option). 

The problem is each row becomes:

Building | City | Repeater XML with everything about all people entered in repeater | Created Date

I need to be able to build an HTML table consisting of

Repeater Person | Repeater Person Number | Building | City  | Created Date

Next Repeater Person | Repeater Person Number | Same Building | Same City  | Same Created Date

What actions would I even use to keep track correctly? It seems like I would benefit from using a collection but the returned XML can only be stored in a single variable. 


23 replies

Badge +5

Hi N J,

are you making use of Nintex workflow here ?

what is your object exactly ? if you are having a form that has the mentioned repeating fields concept and trying to transform data into another list with the way you are thinking to parse, the Nintex workflow that I uploaded here

Nintex Forms Repeating Control two way sync with child list

 might come in handy. in the blog I was doing two way sync thus using two workflows, if you need only one way you can stop with single workflow. to achieve that building information appear along with each repeating row, you can add list look up fields while creating parent item look up field in the child list.

refer to below screenshots for more details

208817_pastedImage_2.png

208818_pastedImage_3.png

Let me know if this helps or your requirement is something different.

Badge +8

It looks like this is something down the same road of what I'm trying to achieve. I'll be more specific though. 

I've got two lists. One has lots of fields, I'll call it the main list. Then I made another list to run queries on the target list for reporting purposes, I'll call it the report list. The report list has a web service call that returns the below information:

[XML] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi= - Pastebin.com 

this is one of 29 returned items from the main list for this specific web service call. I've removed any identifying information. I'm not even sure I'll be able to use this as it looks like everything in the repeater(ows_multiRepeaterDetails) is broken.

Here's a screenshot showing the same item the above XML is regarding. This is with only resident. Each item could have 20 residents.

The output should be a table showing 

ResidentResident NumberMain List Item IDCenterRegionCreated DateMonth ServiceAR TypeMedicare Bad Debt Amount
Person 1Number1212Mississippi2017-10-03 08:08:49JanuaryDEN2200.00
Person 2Number2212Mississippi2017-09-13 08:08:49MarchQWE3400.29
Person 3Number3212Mississippi2017-09-13 08:08:49MarchPOP3400.29
Person 4Number4212Mississippi2017-09-13 08:08:49MarchEWQ3400.29

In this example, you see that Person 3 and Person 4 come from separate items from the main list entirely. 

I have no issue creating the table with the fields that are not inside the repeater. 

Nintex staff: I can't post the returned XML because I keep getting an error:

best I can do is post a pastebin: [XML] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi= - Pastebin.com 

Userlevel 5
Badge +14

Since I have multiple items I'm returning, I need to call web service.

you need not to complicate things with web service, query list action can return multiple items as well.

just make sure you store result sets into collection variables.

I need to be able to build an HTML table consisting of...

it looks like you do not have problems to make a table out of scalar fields.

so here is a possible way to do the same with repeating section

- regardless of how do you get it, either with webservice call or query list action, do following with each item's repeating section field

- with query XML action store each repeating section field/column into a collection variable. you can do that with single query XML action which's set up might look like this

208810_pastedImage_6.png

- then make a for each loop over one of these collections.

save loop index into a variable.

- use collection operation action(s) to pick values from collections populated by above mentioned query list action. 

index variable gives you pointer to all the values of a single repeating section row across all the collections.

store the values into scalar workflow variables.

- now you can use these workflow variables to build related part of output table

Badge +5

As Marian Hatala Moderator mentioned, do not complicate things. you can query list items and use Query xml action to retrieve all your child items and insert them to your child/reporting list along with primary list field data to your reporting list columns.

Badge +8

I have no idea why I thought I couldn't do this with a Query List action.

OK, so I have variable collections set up for Center, Region, Created, Month of Service, AR Type, Amount, and Repeater.

Then, I created collections for Resident Name and Resident Number; columns that exist inside the repeater.

So you're saying to run a query XML against the collection for the Repeater, use XPath to grab the specific values that are useful to me, store them in their collections (Resident Name and Resident Number), and then when it comes time to output them to a notification email or however I'm going to do it, add in the information from the non-repeater values. 

I guess the only part I'm not sure how to do, is maintaining the relationship between the repeating section details and the details outside the repeater. They don't exist 1 for 1, as some repeaters will have 10 entries for 1 item.

What specific actions should I use to maintain the relationship between the values inside the repeater and the details outside the repeater, that it exists on? Here's an example of what I'm afraid will happen.

Item ID 1 is for Region MS. It has 2 Residents. Mark and Marcell.

Item ID 2 is for Region KY. It has 3 Residents. Ken, Kyle, and Kirsten.

When I start iterating through the Residents, what am I using to keep track that Ken, Kyle, and Kirsten don't wind up being linked to MS incorrectly?

I feel like I'm just missing one piece of this and I'm not sure what.

Userlevel 5
Badge +14

the trick is in this paragraph

- then make a for each loop over one of these collections.

save loop index into a variable.

you will need two nested for each loops in your design - one for items returned by (eg) query list action and second to iterate through repeater rows returned from query XML action.

in both for each loop actions you have to save index value to a variable.

then index value from outer loop will identify item field values across all the collection - so, Region[idxItem], Center[idxItem], Repeater[idxItem], etc will all be values of the same item

index value from inner loop (for a given Repeater[idxItem]) similarly will identify values across all the collection that store repeater data, eg ResidentName[idxRsRow], ResidentNumber[idxRsRow] etc.

note the construct Collection[idx] is just to explain it easily. to pick single element out of collection you will need to use collection operation.

hope it clears it out.

Badge +8

Well, I feel closer. I'm obviously not thinking about this the right way or something. Let's assume I want to just attach the outer values to each inner(Repeater section) value and then send that information in a Notification. 

I've got a For Each(OuterLoop) cycling through varCollCreated(the Created field of the returned items) which stores the result in tmpOuterLoop and indexes to idxOuterLoop, after that is doing an XML Query to grab the Repeating section details on that same item to get the Repeating fields ResidentName and ResidentNumber. After that I have another For Each loop(InnerLoop) which stores result in tmpInnerLoop and indexes to idxInnerLoop.

Here is where I'm stuck. I thought that I would use something like Build String to create the string of "Resident Name - Resident Number - Center - Month of Service - Created - Region - Amount - AR Type" but if I tried that at this level, I would wind up with the whole collection of each of those, not the specific entry.

I'm sorry to keep on like this, but I still don't understand the last piece that would tie each InnerLoop value to the OuterLoop value. Maybe I don't understand how I'm supposed to be using the Indexes?

Badge +5

because you already have your outer data in the list item properties you can directly use this kind of table construction inside your nintex workflow 

208885_pastedImage_3.png

and sending this final table to your notification body.

somehow not able to switch this to advanced editor to be able upload the example workflow I built for your problem hence you got to manage with screenshots.

This is how the key steps of workflow would look like 

208884_pastedImage_2.png

Userlevel 5
Badge +14

I think you're on right track happy.png

I'll assume you want to build up structure like this from your original question (slightly updated)

I need to be able to build an HTML table consisting of

 

A: Repeater Person | Repeater Person Number | Building | City  | Created Date

B:   Next Repeater Person1 | Repeater Person Number | Same Building | Same City  | Same Created Date

B:   Next Repeater Person 2| Repeater Person Number | Same Building | Same City  | Same Created Date

B:   Next Repeater Person 3| Repeater Person Number | Same Building | Same City  | Same Created Date

that means the line I labeled 'A' you have to 'create' (add to table string) within outer loop.

lines labeled 'B' you have to add within inner loop.

once you're at the end of outer loop send out a notification (if notification should be sent per each item) and clear table string variable to start over with new table (notification content) with new (outer) iteration

Badge +8

Close, I think. Hopefully the below clears some things up and doesn't just cause a bunch of confusion. 

Let's say my list query returns 3 items. Item 1 has 2 Residents in the Repeater, Item 2 has 2 Residents, and Item 3 has 3 Residents.

My final output should be

Line 1: Returned item 1: Center - Month of Service - Created - Region - Amount - AR Type - Resident Name - Resident Number

Line 2: Returned item 1: (Same as Line 1) Center - (Same as Line 1)Month of Service - (Same as Line 1)Created - (Same as Line 1)Region - (Same as Line 1)Amount - (Same as Line 1)AR Type - Different Resident Name - Different Resident Number

Line 3: Returned item 2: Center - Month of Service - Created - Region - Amount - AR Type - Different Resident Name - Different Resident Number

Line 4: Returned item 2: (Same as Line 3)Center - (Same as Line 3)Month of Service - (Same as Line 3)Created - (Same as Line 3)Region - (Same as Line 3)Amount - (Same as Line 3)AR Type - Different Resident Name - Different Resident Number

Line 5: Returned item 3: Center - Month of Service - Created - Region - Amount - AR Type - Different Resident Name - Different Resident Number

Line 6: Returned item 3: (Same as Line 5)Center - (Same as Line 5)Month of Service - (Same as Line 5)Created - (Same as Line 5)Region - (Same as Line 5)Amount - (Same as Line 5)AR Type - Different Resident Name - Different Resident Number

Line 7: Returned item 3: (Same as Line 5)Center - (Same as Line 5)Month of Service - (Same as Line 5)Created - (Same as Line 5)Region - (Same as Line 5)Amount - (Same as Line 5)AR Type - Different Resident Name - Different Resident Number

Userlevel 5
Badge +14

hm, from your previous post I understood you already have something like this but you don't like it...

anyway, principle is very similar to what I said above: values that are common for several output lines you have to prepare in outer loop. values that are specific per single line (repeater rows) you have to prepare within inner loop.

since you want to join common and per line specific data on each line, you have to put build string action into inner loop.

with 'prepare' I mean that you pick an element from respective collection at current index position and save it into a variable.

eg for Center it might look like this (obviously in outer loop)

208886_pastedImage_1.png

likewise for Resident's data within inner loop

208887_pastedImage_2.png

then use 'prepared' data in build string action to make up single rows, eg.

208888_pastedImage_3.png

‌ html table‌

Badge +8

That's what I was missing. I guess I just wasn't getting it yesterday.

I'm able to iterate through both loops correctly now. Thank you so much.

My only issue now is for some reason, my XML Query is returning the entire XML item even though I have the XPath set like:

 

Userlevel 5
Badge +14

remove trailing "/@type"

I guess you are interested in node value and not value of 'type' attribute

apart of that your XPath seems to be correct. can you test it with Run now and post what result it gives?

if you will not manage to get it working can you post sample of your inout XML?

Badge +8

Yea, I only added the "type" after it didn't work without it. Weird thing is they both return the same information.

Here's the XML I'm building the XPath on. 

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version />
<Items>
<Item>
<dtlCurrentRowNumber type="System.String">1</dtlCurrentRowNumber>
<txtResidentNumberAdded type="System.String">99999</txtResidentNumberAdded>
<txtResMCDAdded type="System.String">Yes</txtResMCDAdded>
<txtResidentNameAdded type="System.String">NAME REMOVED</txtResidentNameAdded>
<txtMedicareNumberAdded type="System.String">NUMBERHERE</txtMedicareNumberAdded>
<txtMonthServiceAdded type="System.String">January</txtMonthServiceAdded>
<txtYearServiceAdded type="System.String">2017</txtYearServiceAdded>
<txtFirstSentAdded type="System.String">9/29/2015</txtFirstSentAdded>
<txtMCRDatePaidAdded type="System.String">10/1/2017</txtMCRDatePaidAdded>
<txtTotalCoinsurDeductAdded type="System.String">2300</txtTotalCoinsurDeductAdded>
<txtTotalPaymentAmountAdded type="System.String">100</txtTotalPaymentAmountAdded>
<txtMedicareBadDebtAmountAdded type="System.String">2,200.00</txtMedicareBadDebtAmountAdded>
<txt35ReductionAdded type="System.String">770.00</txt35ReductionAdded>
<txt65ReductionAdded type="System.String">1,430.00</txt65ReductionAdded>
</Item>
</Items>
</RepeaterData>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

It winds up returning every single Repeating Section Item. It's as if my XPath command isn't processing at all. This isn't the entire list, but here's one of the entries it returns(It returned a total of 7 items like this):

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version />
<Items>
<Item>
<dtlCurrentRowNumber type="System.String">1</dtlCurrentRowNumber>
<txtResidentNumberAdded type="System.String">9999</txtResidentNumberAdded>
<txtResMCDAdded type="System.String">Yes</txtResMCDAdded>
<txtResidentNameAdded type="System.String">NAME REMOVED</txtResidentNameAdded>
<txtMedicareNumberAdded type="System.String">NUMBERHERE</txtMedicareNumberAdded>
<txtMonthServiceAdded type="System.String">January</txtMonthServiceAdded>
<txtYearServiceAdded type="System.String">2017</txtYearServiceAdded>
<txtFirstSentAdded type="System.String">9/29/2015</txtFirstSentAdded>
<txtMCRDatePaidAdded type="System.String">10/1/2017</txtMCRDatePaidAdded>
<txtTotalCoinsurDeductAdded type="System.String">2300</txtTotalCoinsurDeductAdded>
<txtTotalPaymentAmountAdded type="System.String">100</txtTotalPaymentAmountAdded>
<txtMedicareBadDebtAmountAdded type="System.String">2,200.00</txtMedicareBadDebtAmountAdded>
<txt35ReductionAdded type="System.String">770.00</txt35ReductionAdded>
<txt65ReductionAdded type="System.String">1,430.00</txt65ReductionAdded>
</Item>
</Items>
</RepeaterData>;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Userlevel 5
Badge +14

It winds up returning every single Repeating Section Item. It's as if my XPath command isn't processing at all. This isn't the entire list, but here's one of the entries it returns(It returned a total of 7 items like this):

but that's what you want...

that's why you have to save query XML results into collection variables and then iterate over them with inner for each loop.

.... forgot to warn you above that XPath for your 2nd output above returns always value from 1st repeater row.

since you do not know how many rows is in repeating section you should not address single rows but rather get all of them into collection.

Badge +5

isn't it not having index in //Items/Item/fieldName is that problem there for output 1 ?

or may be I worked in different way. just check it out, your output 2 has index mentioned but not output 1.

Badge +8

Sorry, I'm explaining incorrectly. 

Yes, I want the XML query to return all repeating section items. The problem is, it's returning ALL XML as a single entry. I did a count on the Collection and it returns 1. Meaning it's doing a query on the XML, incorrectly returning ALL of it instead of saving just the value directed by the XPath, and then it's incorrectly returning everything as though it's 1 item.

Userlevel 5
Badge +14

can you post what does it return Run now?

for me it works on your data sample

208924_pastedImage_1.png

Userlevel 5
Badge +14

you have there several RepeaterData root elements. that's not valid repeating section structure.

how did you get it?

have you joined repeaters from all the rows into single variable?

you have to process repeaters item by item.

Badge +8

It comes like that from my Query List. I query the list, store the results in collection, query XML on the collection, and I wind up here.

Userlevel 5
Badge +14

store the results in collection, query XML on the collection

that's the problem, you cannot query whole collection (ie. over all the returned items), you have to make query on single collection element.

Badge +8

Ah ha! So I had it out of order. It works now! Thank you so much! This was driving me crazy. I really appreciate you working through it with me. 

Userlevel 5
Badge +14

great!

happy to hear that happy.png

Reply