How obtain row count from nested collection

mbailey

Member
I have a single row collection (call it Coll-A) that has a nested collection as a field (call the field Coll-B). I need to get a rowcount from the Coll-B collection in the only row of Coll-A. The Collection internal business object Count Rows action requires a collection name parameter so I use dot notation inside double quotes and enter "Coll-A.Coll-B". When run, Count Rows throws the error "No collection with the name Coll-A.Coll-B exists." The nested collection exists and is accessible - I populated the collection name field in the action by dragging it from the list of collections, responding OK to the prompt that this should be a text item, and replacing the brackets with double quotes.

I solved the problem by creating an empty local collection data item, using the Utility - Collection Manipulation.Append Rows To Collection action to populate the local collection with a copy of [Coll-A.Coll-B], and taking the row count of the local collection. Append Rows To Collection takes the data item, not the data item name, so I'm guessing that there is a problem with dot notation in the name.

Question: How can I get the row count of a nested collection directly (i.e., without having to copy it to a local collection)?

Thanks,
Michael Bailey
 

VJR

Well-Known Member
Hi mbailey,

Pass the collections [Coll-A.Coll-B] to the Input parameters of the Code stage and give it a name as say NestedCollection.

Then in the code using the below line will return the count of rows in TotRows which is a number passed as an Output parameter in the Code stage.

TotRows = NestedCollection.Rows.Count

There are 3 rows in the TempCollection and hence NoOfRows is displaying as 3.
View attachment 1542259420812.png
 
Top