Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
446 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Looping in Power Automate Desktop Part one of a three-part series of blogs |
---|
How to use the 3 types of Loop in Power Automate Desktop flows
|
In this blog
This blog will show you how to use a simple loop in Power Automate Desktop to ask a user for a password. Here's the basic structure of the flow I want to create:
Ask a user for a password and give them 3 attempts to enter it correctly.
If they enter the correct password they will see a success message and the flow will continue.
If they enter the incorrect password 3 times they will see a failure message and the flow will stop.
From this point onwards I will refer to Power Automate Desktop as PAD.
The simple loop in PAD is often referred to as a 1 to n loop where a loop is performed a specified number of times. To begin, I'll create a new flow and give it a sensible name.
Create a new flow and give it a suitable name.
I need to store the correct password so that I can compare it to what a user will enter later in the flow. To do this, I can add a Set variable action to the flow.
The Set variable action will allow me to create a variable and store the password in it.
I've changed the variable name to Password and its value to (Pass123).
The simple loop repeats actions between the Loop and End actions a set number of times. Add a Loop action to the flow as shown below:
Searching for loop will return the available loop actions. The loop we want is simply called Loop and is highlighted above.
A loop index variable is created that stores the current loop number and increments for each iteration of the loop.
Here's the configuration of the Loop action:
The Loop action requires a starting, finish and increment number for each loop. I've changed the name of the variable to Loop_Counter.
The action will now appear in the flow and I can insert the actions I require to loop.
The actions I wish to perform will be inserted between Loop and End.
Within the loop I need to ask the user to enter a password. To do this, I'll drag a Display input dialog task into the loop.
Its often easier to drag an action into position than double click to insert and then move.
Here's the configuration of the Display input dialog action:
The Display input dialog action will produce an input box for the user to type the reply to the message.
This action produces 2 variables, one to store the user's input and the other to store which button a user pressed.
I've changed the name of the variable to store the user input and switched off the ButtonPressed variable.
Now I will need to test if the password entered by the user equals the password set by the variable at the beginning of the flow. To do this, I can add an If action to the flow.
I've set the If action to compare the password entered by the user to the preset password. The If action is case sensitive in PAD.
Here's what the loop should look like:
The If action within the loop, after the user has entered something into the Display input dialog action.
The next step is to add a Display message action into the If block to show a message when the user enters the correct password. Here's the configuration of the Display message action:
This is the message a user will see if they enter a correct password. I've disabled the Button variable (not shown).
A number of PAD actions have buttons associated with them and will always produce variables for the buttons. Unless you are testing the outcome of which button has been clicked they do not need to be stored as variables. Turning button variables off will reduce the number of variables listed in the variables pane.
If a user enters the correct password I need to exit the loop and carry on with the rest of the flow actions.
This can be done using Go to and Label actions. Start by adding a Label action after the End action of the Loop block:
The Label action acts as a bookmark within the flow that I can jump to using the Go to action.
Now I can add the Go to action after the success message.
The Go to action lists the available labels. Here I'm choosing the name of the label I've just added: Success.
Once PAD has jumped to the Label I need the flow to continue with whatever actions I require. To explain to the user what's happening, I'll add another Display message action after the Label.
I've opted to simply show a message after a correct password has been entered and the flow continues.
The flow so far caters for a user entering the correct password. Now I need to add actions to deal with a False result in the If action. To do this, drag an Else action into the If, placing it after the Go to action.
The Else action is the start of any actions to be performed when the preceding If returns a False result.
Actions added between the Else and End will be performed if the user entered password does not equal the set password.
I'll display a message telling the user they have entered an incorrect password and state how many more attempts they have. Drag a Display message action into the Else block.
As mentioned in previous blogs, you can perform calculations on variables but they must be contained within the % symbols.
After a user has entered an incorrect password 3 times the loop will end and the flow will continue with the next action. At this point I want a message to appear and the flow to stop. Here's what the flow should look like before I stop it:
When the loop ends the flow will continue after the End shown on line 10 in the image.
The message and stop actions must be added after the End of the loop but before the Label action. First I'll add a Display message action after the End:
The message to display after 3 unsuccessful attempts.
Then I'll add a Stop flow action after the Display message:
The procedures for entering a correct password or 3 incorrect passwords are now complete.
To test the flow I will first enter a correct password and see the outcome.
The correct password entered.
The correct password has been entered, the flow can now continue.
The final message showing how the flow continues.
Here's what happens when I repeatedly enter an incorrect password:
The entered password is incorrect. I will use the same password for further attempts.
The message for an incorrect attempt is shown. Note the count of attempts.
Still incorrect and the attempt count has reduced.
As expected I have no more attempts having made the 3 permitted.
The message clearly states the outcome and the flow did indeed stop.
Below is an image of the full flow.
An example of a simple loop in PAD.
See the other blogs in this series for more PAD loops.
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.