cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Collection by index

NawinAnkathi
Level 3
Hello team, How can I read a specific value from a collection without using Loops? For example I have a products collection in which it has 100 records, I want to fetch 40th Row Product name (Products[40]), based on the index or the Field name. Please advise asap. Thanks, Naveen
11 REPLIES 11

Deep.Shah
Level 6
Does ""Filter Collection"" in ""Collection Manipulation"" Object help in what you are trying to do? Regards, Deep Shah

JiriPospisil
Level 4
Utility - Collection Manipulation Action: Read Collection Field

NawinAnkathi
Level 3
Thank you Deep and Jiri for your responses. Is there any way to directly consume a row from collection using its index or column/field name ? Ex: Products[40] or Products[""Column Name""]

SrinivasaRaoPat
Level 2
Yes. You can copy rows from collection by using Index of the particular row. use VBO: Collection Manipulation Action: Copy Rows In Copy Rows action you can mention Index of the row and also you can mention how many rows to copy from that index if you want.

NawinAnkathi
Level 3
Thanks Srinivas for your response. I am just exploring the ways of fetching data from a collection. Apart from Loops or VBO: Collection Manipulation, is there any other way to fetch the collection value using the index similar to the programming languages. CollectionName[0] or CollectionName[""FieldName""]

Anonymous
Not applicable
I think the function you're looking for is provided in Utility - Collection Manipulation => Read Collection Field where you can provide input parameters as Collection, Field Name and Row Index. The Output is then Value Read which you can store in a variable for further actions. But for some reason, I cannot make it work even in a simple test case. But that's likely because of me, not the object.

Anonymous
Not applicable
If you're looking at this functionality, could you help me out, please? I created a sample collection ""cTest"" with a field ""fTest"". Then I typed a few Initial Values for fTest like vTest1, vTest2, vTest3. When I use Utility - Collection Manipulation => Read Collection Field and define the Inputs as Collection = cTest Field Name = fTest Row Index = 2 and Output to Data1(text), I get an execption ""The collection does not contain a field with the name 'vTest1' ??? So, instead of reading / returning the value from the second row (=> vTest2) it's giving an error stating that there's no field named according to the value on the first row (vTest1).

Hi Juke, I think you might have given Field Name = cTest.fTest, that is the reason its not able to understand the Field Name.. If this is the case, give Field Name = ""fTest"" (only Field name without Collection as a prefix).. Hope this helps 🙂

TomBlackburn1
Level 7
Code Stage: myOutput = myCollection.Rows.Item(Convert.ToInt32(myRowNumber)-1).Item(Convert.ToInt32(myColumnNumber)-1) Let me know if you need me to explain more.