I could not able read and write value into same datatable in a single for each row loop

Steps followed:

  1. Read an excel and assign it to the datatable (DT)
  2. Add column : "Error message details " at the end of data table
  3. Read the row using For each row loop
  4. Filling a text box Promo id in the application
  5. Check if error pop up comes (Promo id value not in DB)
  6. when an error pop up comes: Need to update the "Error message details " column into the datatable(DT) as “Failed”

Issue: I try to assign the value of row(“Error Message details”) = “Promo id error” | Assign row.item(32) = “Promo id error”. getting an error as in the below screenshot(everytime when i try tio assign some value to it

the issue could be the selector you are using for the element exists activity

1 Like

You can not use Assign Activity for writing any value to Column. To achieve this use Write Range Activity.

@ronanpeter - I tried moving inside a if loop as well, But still the issue continues

Thanks for your response

Hi @subash8993

The structure of both the datatables should be same, the one you read from an excel and the one you are using for add data row to the new datatable, if you you are adding column to the same datatable after reading the excel, you can use build datatable with same amount of columns from an exce and your new “Error Message details” column, then try adding data inside loop

1 Like

@md.kashif464 - To Clarify it, I want to include that “error message” to a column in datatable from which i fetch the data(Promo id) - Not to column in excel(i.e - i dont to write this error message to an excel)

Thanks for your respone

@gowthamvijay - Since i have to post the entire result in to another output sheet, i dont want use two different datatable.

More over, i could not able to use two different datatable in a single for each row loop, Kindly help me by providing a solution for adding the error value in specified column of the same datatable

Please note: I am using a single data table to input values, if i find an error message i need to update the error in the same data table and proceed with the execution

Thanks for your response

@GouthamVijay - There are chances that the excel template can vary, Hence need a dynamic way of handling it

Please refer thisnew.xlsx (7.8 KB)
Main.xaml (7.4 KB)

You can vary the logic accordingly, if you want in loop you can pass in the loop.

Goutham Vijay

@GouthamVijay @md.kashif464 @ronanpeter @ClaytonM

I have reproduced the error kindly help me resolving the issue, Kindly keep the unzipped file in desktop and run it. You will get the error

read and write issue.zip (27.0 KB)

Hi @subash8993

I think you have made a small mistake while writing the data to the website,
You have used : row.Item(1).ToString
instead of row.Item(0).ToString
always row items starts with 0.

This is the reason you are not able to write the error message into the excel,
Please attach the following workflow:
Main.xaml (19.7 KB)

Goutham Vijay


Thanks its working fine for the scenarios. i am handling a data of more than 40 fields, where i get a similar type of error when i take the error message. Any idea?

Could you explain in detail?

If you are solved with your problem, mark it has solved so that it might help others.

@GowthamVijay The issue is not resolved, since i am adding a new row at position 2 i.e row.item(2). Still i could not add an entry in it

As per your excel input “Error message” column exists in row.item(1)


I have added a new column at the excel scope