Unable to exit For each loop

  1. I am using For each loop to read data from excel file.
  2. I have 2 records in excel file.
  3. My automations reads 2 records successfully from excel file and inserts them in the service now web application.
  4. After 2 records the loop is continued without ending the automation.
  5. How to end the automation after reading all the records from excel. ?
    Please help…

Screenshots attached for reference


Hi @shruthi_arali

Please use “Break” activity. which will end the loop

hope this works.

Please tell me how to use break activity after inserting all the records from excel file

Hi @shruthi_arali

Can you please try using WorkBook “Read Range” instead of Excel Application Scope “Read Range” and pass the DataTable(the output from Read Range) to “For Each” loop , that should exit the loop automatically after completing all the records in excel.

image

Hi @shruthi_arali

Just remove the filter from the excel file and check.

Use message and bind the value

Dt.Row.count

If possible can you share the sample input and xaml file

Regarad
Gokul

@Gokul001

please find the input file and xaml.
Incident - Mandetory Fields.xlsx (94.0 KB)
Main.xaml (52.1 KB)

Hi @shruthi_arali

Which sheet need to be use for looping through the for each row in Data Table

Regards
Gokul

Hi @shruthi_arali

I can’t able to test the workflow.

I have modified some changes inside the workflow check and let me know

Main (5).xaml (55.2 KB)

Regards
Gokul

@Gokul001 … I tried your logic but the execution is stopping after reading first record from the excel… It is not going for second record.

HI @shruthi_arali

Try to check this condition

CountInt<=DT.Rows.Count

Have a look on the SS

image

Regards
Gokul

@Gokul001 … same issue again it is reading only one value from excel. :frowning:

Hi @shruthi_arali

Can you try to print the DT.Rows.Count and share the ss

Regards
Gokul

Hi @shruthi_arali

Your Excel Dt Count is 6

You can try to Delete the range after the values

Here is the workflow

DTconlooping.xaml (8.5 KB)

Regards
Gokul

@Gokul001 … Please find the ss below

HI @shruthi_arali

Just Delete the range from the excel file that i mention in the above post.

Or Else

You can copy only the data from the excel and create a new excel and past it and run the process

Regards
Gokul

1 Like

@Gokul001 … Thank you so much… :slight_smile:
It worked…

Great @shruthi_arali

Happy Automation

Regards
Gokul

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