Add Data Row overrides old value from Data Table

Hi :wave:

i’m currently stuck with the following problem:

I am scrapping Data form a Data Table, then i check if the scrapped Data Table (“dt_Workitems”) contains some specific values. If the Data Table contains the searched values then it should be added to a new Database (called “in_dt_new_Workitems”). If it doesn’t then it should continue to the next page, scrap and check again for the specific values.

The problem that i’m currently facing is that instead of adding a new row to “in_dt_new_Workitems”, it overrides the old value with the new. But i just want to add it in a new row.


grafik

So basically, the “dt_Workitem” Data Tabel always got new values for each scrapped page. The idea was to check if the dt_Workitem contains the specific values and in the end to have the “in_dt_new_Workitems” to just contain the desired informations/values from the scrapped Datatables.

Any idea why it isn’t just adding the data into a new row? :thinking:

1 Like

Hi , In Array row property give value as Row.ItemArray

remove the ‘datarow’ property value

The problem with your code is you have used DT.Newrow , which creates new empty row in the Datatable

1 Like

Fine
inside the THEN part of if condition
–remove the ASSIGN activity with select method-----this is the main issue as it will over ride the data…
–so use only ADD DATA ROW activity and in that remove datarow property and mention in the ARRAYROW property as row.ItemArray and in the datatable mention as in_dt_new_workitems

or

to be very simple remove all these FOR EACH ROW activity and mention only the assign activity like this
in_dt_new_workitems = dt_Workitem.Select(yourcondition).CopyToDatatable()
anyhow it is going to do the same and is more faster than above method

hope this would help you
Cheers @Mod0091

1 Like

oh, thanks. At least this time i got two rows in my data table. But the strange thing is, that its the same value? actually it should have two different values.

Thats fine buddy
the select method would filter anyhow
did the above steps helped on this
kindly let know for any queries or clarification
Cheers @Mod0091

@Palaniyappan you mean like first add data row activity and then remove data row activity?

Fine
either we can have only assign activity with that select method expression without using FOR EACH ROW activity
in_dt_new_workitems = dt_Workitem.Select(yourcondition).CopyToDatatable()

or
if we want to use FOR EACH ROW loop, remove the assign activity inside the THEN PART and keep the add data row activity alone within the THEN part of IF condition
–where in the add data row activity mention the arrayrow property as row…ItemArray and remove the datarow property and mention the datatable as in_dt_new_workitems

Cheers @Mod0091

yeah, i’ve to use the for each activity because i’m working with dynamic selectors. If i don’t use the for each activity it starts logging out of acme after scraping a page and try logging in again etc.

ok, i’ll try that! Thanks for the idea!

1 Like

Hi There, please have a check if this demo helps you: How to Use DataRow Argument in Add Data Row | Add Data Row Activity | Add Data Row UiPath Example - YouTube