Hi devs, I want to update rows with values from list of string but it’s only populating one item from the list into the rows. Example I have several addresses but it’s updating only one address. “johan”, “Melbourn”, “Swiss” etc, it only picks Melbourn
how are you updating the row?
I am using row.setField(“Address”, listItemVar)
Maybe you have placed ListVariable(1).ToString?
If so then it will always take the second element only
As index starts from 0
Hope this may help you
Thanks
Dim ColumnInListAddress As String
For Each item As String In in_listAddressString
ColumnInListAddress = item
For Each row As Datarow In dt.Rows
row.setField("Add", ColumnInListAddress )
Next
Next
Hi @RPA-botDev ,
We could simply use Add data Row
Activity to populate the rows with the values present in the List of Strings.
Is there a Reason you’re not using it ?
I used add data row but it was appending the data to the already existing data, I want to start from first row
Could you provide us with an Input and Expected Output Samples ? if not Screenshots of it should be fine as well.
You could give a Try on the below Approach as well and Check if it works :
Let us know if the above method doesn’t work and what was the Error you encountered.
Your code overwrites the column “Add” several times. That column will always be filled with the last value from in_listAddressString at the end.
If you want to fill the column “Add” with values from the list, starting from the first row, use the code below:
Dim ColumnInListAddress As String
Dim index As Int32 = 0
For Each item As String In in_listAddressString
ColumnInListAddress = item
If (index < dt.Rows.Count) Then
dt.Rows(index).setField("Add", ColumnInListAddress )
Else
Exit For
End If
index = index + 1
Next
That’s true ptrobot, it’s looping correctly now, will inform you once I’m done
Hi ptrobot, I have updated that, pls I have another requirement to compare the list of string with rows(sortcode). if the sortcode on listString above is same with rows(sortcode) in dt.rows update the address on that rows.Pls assist
Hi! Could you create a new topic? Also, could you explain in the new topic with images what you want? It’s a bit unclear from your description. We would need an example with the input table, input list(s) and the expected output table.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.