Invoke workflow issues using while loop


#1

Excel data

URL,UserName,password
gmail.com,xyz,123654
gmail.com,yt1,789654
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 (10.4 KB)
1-Invoke_Guru_Cust_EntryForm.xaml (9.5 KB)
Guru99Cust.xlsx (9.9 KB)

Thanks
Sreenu


#2

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.


#3

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


#4

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

Cheers