Check id and write data according to that in table


In my for each loop im writing many places data to the sheet acoridng to result. and every time i write its add same ID to next row and then adding data to it.

Add DATA Row have this value means im writing like an DataArray
{ID,"","",“Error: All ready writen off”}

ID, Name, Price, Error
1, martin,
1,no data , 120,
1,no data , no data, error on field

Is there a away to avoid that.

Set a variable for the row index (e.g. RowIx) in the For Each loop and use that to set the ID. This will increment by 1 for each iteration starting at 0.

I created a variable RowIndexDT as an Int32 with default value 0.
Now wher i can use that in Add Data Row?

In ArrayRow or in DataRow?

Best to use ArrayRow in this case.

But how can i add rowindex variable in that…

{RowIndexDT,"","",“Error: All ready writen off”}

but that will not write ID ?

Can you give example…

The first variable should be the one holding the Int32 value of the row index. (2,2 Ko)

I’m checking your example … while can you anwer on this question…
sometime i get error on rading ID it sayd system.double can not convert to system.string.
how the ID should be in excel so that uipath except?
can i write to 2 different sheet in same datatable? if yes then how should i devide the column name? and reffer in Arrayrow

  1. You can convert a double to a string. You just have to do it explicitly. If MyDbl is a variable of type Double, you can assign MyStr of type String to MyDbl.ToString.

  2. It would be best to have a separate datatable for a separate sheet.

OK thanks…

Do you means that in every place where I’m adding (add data row) in the value of array I should start from {RoxIndexDT, and then further column value}?

Yes. From there you can update the remaining data in that row.

I tried but its not write or not what i want…
It’s adding 1 value in first column… and I want act ID number…
Let me explain what i want…
Im getting ID and other data realted to that from Excel via Excel Application scope and then im doing read range… After read rang I’m using For each row activity to read each row one by one and do lots of other steps.
Every time I continue from one step to another I write reasult to Table and as im doing all steps by being in for each row loop… so i want to be sure that when I write to table I write all value of ID 1 in one row columns.
let say i write 3 time

1 time I add… {123,“anthony”,"",""}
2 time i add . {123,"",“Humphries”,""}
3 time i add {123,"","",“Error: All ready writen off”}

write now my script is adding 3 rows Excel …because i write in threee different time… But My ID is same so I want that Add data row should now add 3 row… it should fiur out if ID is same then add all data to the row…

@Anthony_Humphries please reply…

Oh, so in that case you can add a data row using the Add Data Row activity and passing {123, “anthony”, “Humphries”, “Error: All ready writen off”}. Except in this case, 123 would be your row index.

I am using Add data row but its adding new line means every value in new line …


I am in a loop but in the new invoke flow… not same flow where i have the For each row loop activity… its addind the new line. and I want that It’s just add the column 5 value into the first line not in second line.
I tried with not adding the ID in this array but then it’s giving error to me.

If the row already exists, you’ll need to use Assign to update a column value for that row. Add Data Row should only be used one time when creating the row initially and not for each column you need to update.

@Anthony_Humphries @Palaniyappan

can you please help me how to update a column in a table and how to find if the row already exist or not.
As i have never tried update a column in table…
please help…

@Anthony_Humphries please help …
no one is replying on my post Do not know if UiPath have banned me on forum or what…

I created small script to see if i can update a row by spacify ID value and it workes…BuildDataTable.xaml (12.3 KB)

but when I use the same log is my orignal file it is not updating the value … can you tell me what i’m doing wrong in my script.
the only change in my orignal script is that im changing if value …
rest is same as my test.
please help