How to find row index in collection?

HI!

You can go through your collection and compare your searchable value with the value in row of the collection ([Collection.Column1]=[Search value])
If they are equal - go out from loop and use item "row number", if not - increment row number ([Row number] = [Row number]+1) and move on through loop.

View attachment 1544776192134.png
 

sivagelli

Well-Known Member
There is no built in action that returns row index. So i am thinking of two solutions-

#1. Loop thru the collection, with a Counter starting from 1 and a decision stage for checking the collection.field = "QCA0700". If Yes, End the loop and your Counter value is the index. Otherwise loop thru the collection increasing the Counter by 1 each time, till the match is found.

OR

#2. Add a Dummy Column, lets call it Index of Number type using Append Field (Number) action and fill the row values using loop. Your collection will have a Index value for each row which indicates the row index. Now, use Filter Collection action and read the Index value from the Output collection of Filter action.

Hope this helps!
 
  • Like
Reactions: VJR

VJR

Well-Known Member
I am trying to find a value(i.e QCA0700 ) in collection and I want to read the row index of the value i.e QCA0700
After getting the row index I want to use it in match index field i.e using dynamic. Can someone guide me.

My collection looks like this
View attachment 2801
To pass that row index in param
View attachment 2802
Hi Divyarani411,

Both the approaches provided by sivagelli are correct.

There is one customised code already in the forum which you can make use of if you intend to avoid any looping, and there are only minor changes need to be done to an existing action.

Refer Post #6 and #7 - The Collection Contains Value is used to return the Row Index when you search for any value in the collection. Let me know if you need to understand anything.
 

VJR

Well-Known Member
Yes, custom code can always be a solution ;)
True, in some cases folks are reluctant to use a Code stage, either because of a non-programming background or due to restrictions in their organizations, in which case both the solutions provided in your post are the best fit.
 
Top