# Invoke workflow issues using while loop

**URL:** <https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991>\
**Category:** Help\
**Tags:** excel, system, activities\
**Created:** [October 18, 2017, 6:11pm UTC](https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991 "2017-10-18T18:11:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreenu\_uipath](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@sreenu\_uipath](https://forum.uipath.com/u/sreenu_uipath)\
**Post date:** [October 18, 2017, 6:11pm UTC](https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991/1 "2017-10-18T18:11:37Z")

</div>

## Excel data

## URL,UserName,password [gmail.com](http://gmail.com),xyz,123654 [gmail.com](http://gmail.com),yt1,789654 [gmail.com](http://gmail.com),aaa,741258

1.i have created sequence using Excel application scope and read the data using Read Range.(Data table : ExcelOutput)  
2. countofrows = excelouput.rows.count  
3. drag while activity and given conditon as below

i\<=countofrows

– and created a varaible URL,UserName,Password and pass the below condtion  
URL=exceloutput.rows(i).item(0)  
UserName=exceloutput.rows(i).item(1)  
Password=exceloutput.rows(i).item(2)

i=i+1

–end while loop

## **Issue 1 in while loop condition if i use = operator i am getting index out of range exception in URL**

create invokeworkflow file

added here above created specific workflow file

in import argumenet , assigned same variables

-open browser(URL)  
-type info -Username  
-type info - password  
-click - login

if there is no equal operator used in while condition then run the invoke workflow and taking first row only.  
here loop not working.

Please review attached sheets and let know where did i mistake.

[0-Guru\_Cust\_EntryForm.xaml](https://global.discourse-cdn.com/uipath/original/2X/2/25ec644aa882d202c4bdf5249dc3ad306bec3b8b.xaml) (10.4 KB)  
[1-Invoke\_Guru\_Cust\_EntryForm.xaml](https://global.discourse-cdn.com/uipath/original/2X/f/f680fb4e307d86aa4a04de6b2775cee6bce9a5f8.xaml) (9.5 KB)  
[Guru99Cust.xlsx](https://global.discourse-cdn.com/uipath/original/2X/f/f562aa09e0857580a090c995d67203e7d81c5a1f.xlsx) (9.9 KB)

Thanks  
Sreenu

---

<div class="post-metadata">

**Author:** ![ClaytonM](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/claytonm/32/555957_2.png) [@ClaytonM](https://forum.uipath.com/u/ClaytonM)\
**Post date:** [October 18, 2017, 6:25pm UTC](https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991/2 "2017-10-18T18:25:01Z")

</div>

Have you tried setting the default value of the variable ‘i’ to 0, so it starts on zero?

Also, it seems that you will want to place your website steps inside the Loop so it can process each line into the site.

I do have an alternative solution to your While Loop and counter, though…  
**Use a ForEach loop.**  
So you can set that up with a “ForEach row activity”  
and will look like:  
**ForEach row In GuruCustTable**  
Assign URL = row.Item(0).ToString  
Assign UserName = row.Item(1).ToString  
Assign GuruPassword = row.Item(2).ToString

so it eliminates the need to know how many are in the list of rows. You can use the ForEach for arrays as well.

Hope that answers your issues.

---

<div class="post-metadata">

**Author:** ![sreenu\_uipath](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@sreenu\_uipath](https://forum.uipath.com/u/sreenu_uipath)\
**Post date:** [October 19, 2017, 4:24pm UTC](https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991/3 "2017-10-19T16:24:29Z")

</div>

Hi @ClaytonM

Thanks for reply.  
I have followed your steps, still loop process with 1st row and stopped there . not able to taking 2nd line.

**ForEach row In GuruCustTable**  
Assign URL = row.Item(0).ToString  
Assign UserName = row.Item(1).ToString  
Assign GuruPassword = row.Item(2).ToString

Please correct me if i am wrong.

Thanks

---

<div class="post-metadata">

**Author:** ![Florent\_Salendres](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/florent_salendres/32/74617_2.png) [@Florent\_Salendres](https://forum.uipath.com/u/Florent_Salendres)\
**Post date:** [October 19, 2017, 7:25pm UTC](https://forum.uipath.com/t/invoke-workflow-issues-using-while-loop/13991/4 "2017-10-19T19:25:51Z")

</div>

Hi,

The problem you have is that firstly you invoke the first workflow containing your loop logic and after its full execution you are processing the open browser and UiAutomation scope, once.

Effectively your looping trough your Datatable and setting value 3 times on your OutArguments (URL,Username, GuruPassword) but only the values from the last row will be passed to your Main workflow, each iteration will overwrite previous values let by the previous row

If you want the Ui Automation to be executed for each row, you would need somehow to put your automation (open browser scope) sequence inside the loop or use a For each Row as @ClaytonM recommended

From what i see you, from the existing file you shared, just “cut” your open browser sequence and paste it inside 0-Guru\_Cust\_EntryForm, inside the loop just after the variable are assigned.

It should be achieving what you want

![image](https://global.discourse-cdn.com/uipath/original/2X/9/9f7ceb546ff17f3bc2cc7a95565472da333f3c4d.png)

Cheers
