Continue on For Each Row Activity and Note Errors

Hello everyone,

I have an issue. I have an excel file which contains input data for a website. I have 7 columns and multiple rows. Each row must be entered to the website as a form. Here is what I did up to now:

  • In an excel application scope, I used read range activity and created an output datatable.
  • Next activity is for each row. In the body section I am using try-catch activity, in the try block I have all the actions (creating variables for excel column values, clicking and typing into the website areas, submitting the form etc.)
  • In the catch block I have system.exception statement in case of any errors.

What I want is, if any error occurs during any row (saving is not done), it should move to the next row. But also I need to know which row the error occured. Because after the automation, I will enter them to website manuelly. I thought that, in the excel file maybe in a new column I can write their status like OK/NOK for each row. But I don’t know how to do that. Should I include this steps in the catch block? Writing only NOK records on a notepad works just as fine, I just need to know which ones haven’t been created in the website.

Thank you.

Hi @alottawarmh ,

I will add few steps in your solution:

  • In an excel application scope, I used read range activity and created an output datatable.
  • After Reading the data use ‘Add Data Column’ activity to add a new column called as status.
    image

Provide column name of your choice , eg, ‘Status’, TypeArgument as String and data table variable will be the same as you use in read range

  • Next activity is for each row. In the body section I am using try-catch activity, in the try block I have all the actions (creating variables for excel column values, clicking and typing into the website areas, submitting the form etc.)
  • At the end of all the steps use an assign activity row.item(‘Status’) = OK
  • In the catch block I have system.exception statement in case of any errors.
  • Use logging in catch section, also use an assign activity to write row.item(‘Status’) = NOK

If in the body of For Each Row you are using try catch, in case error appears in say row number 1 , bot will go to row number 2 and so on…

you can write the whole set back into excel using write range activity (Same data table variable that you have used above, Headers checked ) after the for each row loop—> this step goes as per your need!

2 Likes

@JuveriaSiddiqui Thank you very much for your response. I have below problem with assign activity:

Adsız2

Sorry it might be a stupid question, but I am very new here:)

Also logging in catch section is log message activity? By the way this process will be performed only once, so I am not going to need Orchestrator.

Check extra dot

1 Like

Hi @alottawarmh

Can u try with as below

row(“Status”)= “OK”

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed:

1 Like

Thank you all, I solved that issue. Right now I am not getting any errors.

I also want to ask this, my for each loop ends with click activity on the save button. After that website might throw an error saying “this record already exists” or something else. But the bot completes the clicking action, so its status is written on excel as “OK”. How can add this control within the loop so that it counts as “NOK”?

Hello @alottawarmh ,

For your second question, you should do some more steps.
After click, use an activity like Element exist/Image exist to see if the error appear.

If appear, put the status like NOK, if does not appear put OK.

I hope it helps.

Vasile.

1 Like

Thank you, @wasea. It’s working perfect with element exists activity.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.