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

#1

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

#2

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

1 Like
#3

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

#4

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

Thanks for your response

#5

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
#6

@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

#7

@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

#8

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

#9

@subash8993
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.

Thanks.
Goutham Vijay

#10

@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)

#11

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)

Thanks.
Goutham Vijay

#12

@GouthamVijay,

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?

#13

Could you explain in detail?

#14

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

#15

@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

#16

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

#17

@GouthamVijay

I have added a new column at the excel scope