cancel
Showing results for 
Search instead for 
Did you mean: 

populating a field in a collection with a data item?

LisaMartino1
Level 3
Hi there,
I thought this would be something simple but I have become stumped and hoping that someone might be able to help?

> I have read a table into a collection
> one of the fields in that table is blank in this example: ID
> I have the ID in a data item
 My question is, how do I populate that data item into row 1 of that field within that collection? - highlighted in Yellow.
12955.png

My intention was to populate row 1 then update the data item and then update row 2, etc....

------------------------------
Lisa Martino
------------------------------
1 BEST ANSWER

Best Answers

NicholasZejdlik
Level 9
You can use a calculate stage to set the value of a field for the currently selected row. The expression in your example would be [Data Item] and store-in would be Collection from an HTML table.ID. Use a loop to iterate over all of the rows of the collection.

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------

View answer in original post

6 REPLIES 6

Yeswa_Vaibhav_1
Level 6
Hi Lisa,

Does your table always have 1 entire field as empty (i.e., in above scenario ID field). If Yes:
There is no option to update the collection field row by row. (i.e., in your case ID field of 1st row then 2nd row etc.)
Instead of that you can append all the Data item values of "ID" field into a separate collection (i.e., in that the collection will have only 1 field and should be with same field name as in your main collection). Once all the Data items were appended to new Collection, remove the ID field in the original collection using "Delete Field" Action in Collection Manipulation VBO, then use "Merge Collection" Action to combine these two collection and you will have your Collection with "ID Field" filled in it.

Please let me know if it is not clear or if I missed anything.

------------------------------
Yeswa Vaibhav Alwar Nerella
Associate Consultant
Capgemini
Asia/Kolkata
------------------------------

NicholasZejdlik
Level 9
You can use a calculate stage to set the value of a field for the currently selected row. The expression in your example would be [Data Item] and store-in would be Collection from an HTML table.ID. Use a loop to iterate over all of the rows of the collection.

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------

Thank you!! This worked!  I used a calculate stage and a loop.  I appreciate you taking time out of your day to answer my question. ​

------------------------------
Lisa Martino
------------------------------

This answer is great. But can you can please also tell me how to do this if the field in the Collection is dynamic.

------------------------------
Soumya Behera
------------------------------

Use Get Collection Field / Set Collection Field in the Collection Manipulation object. Those two actions accept a dynamic field name and row index. Because they work off a row index, that means a loop is unnecessary; rather, you will want to use a row index and increment it to go over the whole collection (the equivalent of a for-loop).

------------------------------
Nicholas Zejdlik
RPA Developer
------------------------------

Set Collection Field is working for me. Thank you so very @Nicholas Zejdlikmuch.​

------------------------------
Soumya Behera
------------------------------