I am using For each loop to read data from excel file.
I have 2 records in excel file.
My automations reads 2 records successfully from excel file and inserts them in the service now web application.
After 2 records the loop is continued without ending the automation.
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.
Gokul001
(Gokul Balaji)
March 8, 2022, 8:07am
5
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)
Gokul001
(Gokul Balaji)
March 8, 2022, 8:59am
7
Hi @shruthi_arali
Which sheet need to be use for looping through the for each row in Data Table
Regards
Gokul
Gokul001
(Gokul Balaji)
March 8, 2022, 9:09am
8
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.
Gokul001
(Gokul Balaji)
March 9, 2022, 6:00am
10
HI @shruthi_arali
Try to check this condition
CountInt<=DT.Rows.Count
Have a look on the SS
Regards
Gokul
@Gokul001 … same issue again it is reading only one value from excel.
Gokul001
(Gokul Balaji)
March 9, 2022, 6:07am
12
Hi @shruthi_arali
Can you try to print the DT.Rows.Count and share the ss
Regards
Gokul
Gokul001
(Gokul Balaji)
March 9, 2022, 6:14am
13
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
Gokul001
(Gokul Balaji)
March 9, 2022, 6:26am
15
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
@Gokul001 … Thank you so much…
It worked…