cancel
Showing results for 
Search instead for 
Did you mean: 

Collection - Start looping from row X

shahariar_k_bhu
Level 5
Lets say that I have a collection consisting of 1000 rows. I was wondering if there are any possibilities to start counting/looping from a certain row and to a certain row? For example, lets say that I have a person register where I separate persons into groups: Main Collection looks like this: Group | ID | Name ----------------------- A | 12sdkj2 | Peter A | 3948sd | David B | difu3oj | Susan etc.... I also have a collections which keeps tracking the group name, start row, and end row. Group | Start Row | End Row ------------------------------------ A | 1 | 2 B | 3 | 47 Let's say that I'm looking for a certain person in group B. Is it possible for me to start looping from row 3 to 47? So I don't have to loop through the whole collection to find this person. Btw, I know I should use code in order to achieve this, but I'm currently experimenting the limits by staying with only actions.
4 REPLIES 4

Graeme__Tacon
Level 6
You could use the 'Copy Rows' action in the 'Utility - Collection Manipulation' object to copy the rows you are interested in to another collection and loop around that.

Hmm, I didn't think of copying the rows in to a new collection. Thanks for the suggestion, I'm going to try that out!

Ed_PaulSantos
Level 3
What you can do is just create a decision stage inside the main collection loop to check for the Group field. Else, skip to the next item. Then create a Flag to check if the loop should end already to prevent the robot from looping in the whole collection.

Jared.Rumball
Level 6
Why do you need the second collection tracking the start and end rows? Seems like a recipe for unnecessary maintenance and potential errors. But of course, depends on the requirements and your use case may be valid. Just curious.

Anyway, another option to those already suggested would be to filter the first collection based on the Group and then work on the result. That way you don't need to use the second tracking collection (at least not for separating out the Group you're interested in), and you don't have to loop the entire collection and test each row.

Additionally, if you know more than just the Group then you could potentially filter the first collection directly to the person you are looking for (if you know the ID), or to a subset of potentials (if you have a partial name for example).

Using the Collection Manipulation utility object can be a bit tricky to begin with if you're not accustomed to how the actions operate, but once you have worked out the required inputs and outputs it's pretty straight forward.

For your example, if I set up a dummy collection to match your spec's, you can see there are nine rows across three Groups:

22244.png
To filter down to a particular Group, the action parameters look like this:

22245.png
Note the format of the filter expression. The filter parameter (i.e. the [Filter Group] part) needs to be enclosed in single quote characters, when it is a text field at least: 

22246.png
If it helps, you can think of this as being like an SQL query.

The result from this when [Filter Group] is set to "A" is the three A group rows in the specified output collection:

22247.png
I specified a different collection as the output parameter from the filter action, but you can actually send the result back to the same collection. Just be mindful of when and how the collection gets populated as once it's overwritten with the filter output... 

If you know the ID of a particular person, then simply alter the filter expression to something like "ID = '" & [Filter ID] & "'" instead

22248.png

Or, make your filter expression more complex depending on your needs...

22249.pngWhich results in:
22250.png



------------------------------
Jared Rumball
Q4 Associates Ltd
https://www.q4associates.biz/
------------------------------