Select Page

Power Automate Tips and Tricks

2021-03-02

Power Automate is my favourite recent tool from Microsoft.

If you want to automate tasks between online services, then you need to learn how to use Power Automate.

In this post, you’re going to learn my favourite tips and tricks for building cloud flows in Power Automate.

Rebranded from Flow

Microsoft Power Automate was originally named Microsoft Flow but was rebranded in 2019.

This means you might still come across the Flow name when searching online for how-to type articles. Just be aware they are the same thing.

If you don’t find your answer searching with the power automate keyword, then try the search with Microsoft Flow instead.

Rename Your Actions

Each action you add to your flow will have a default name. Renaming these can help you to better document what your flow is doing.

Always rename your action and always rename them right away after creating them.

This is important as dependent actions you might add later on will reference these names behind the scene and if you rename them at a later time the dependencies might not always update to the new names.

Click on the three dots on the left of the action and select Rename from the options. Keep your names as short and descriptive as possible.

Add Comments to Actions

Comments in your actions can help you organize and understand your flow when you or someone else comes back to it at a later date.

Click on the three dots on the left of the action and select Add a comment from the options.

You can then add your comment and press Enter. The comment will appear at the top of the action where it is easily readable.

Skip the New Flow Steps

Creating a new flow is a bit too lengthy for my liking with too many unnecessary steps.

If you dislike the many steps, then you can skip them. When you create a new flow press the Skip button without filling in the flow name or selecting the trigger.

That will take you to the new flow builder page. Now if you want to always skip the previous steps, all you have to do is bookmark the URL for this page and then use that to create new flows.

https://canada.flow.microsoft.com/manage/environments/Default-402129a4-69d7-4aba-92e1-fab5483cc399/flows/new

Your URL will be different, but it should look something like the above one depending on your region and environment.

View More of the Flow

When you build large and complex flows, the builder screen quickly becomes too small to view your entire flow.

You can leverage a feature in most browsers like Google Chrome to zoom out.

Hold the Crtl key and press the minus key to zoom out and give yourself a bit more real estate to view your flow.

You can also access the zoom feature by holding Ctrl and using the scroll wheel on your mouse if you have one.

Download a Run History CSV

It’s possible to download the run history from the last 100 runs or last 28 days for a flow (whichever is less).

To do this you need to go to the details screen of the flow and select All runs.

At the top you can click on Get .csv file to download the run history.

This will have a row for every run with various columns for each action in your flow. There is a lot of detail to be found here and can be quite useful for troubleshooting flows by looking at multiple runs.

Copy and Paste Actions

You can quickly reuse actions by copying to the clipboard.

Click on the three dots menu in the action which you want to copy and then select Copy to my clipboard.

After you copy an action, it will be available in the My clipboard tab when choosing what action to add.

This is an exact copy of the action including any static text, dynamic content or expressions in the inputs.

Paste Action as Text

It’s not obvious, but after you copy an action to your clipboard, you can paste it as text into any text editor using the usual Ctrl + V keyboard shortcut.

You’ll be able to see all the action’s inputs along with a lot more!

Paste Text as Actions to My Clipboard

The previous tip might seem a little useless until you realize you can paste text back into the My clipboard tab when adding actions.

This means you can paste an action as text and then perform a find and replace and paste the results back into power automate!

A very handy time saver compared to manually updating action inputs with a new data source.

Hover to See Underlying Expressions

When you add dynamic content to an input, you are really adding an expression. You can view the underlying expression for the dynamic content by hovering the mouse cursor over the dynamic content block.

Paste Expressions with @ Symbol

The @ symbol is used in Power Automate to denote an expression.

convertFromUtc(utcNow(),'Eastern Standard Time','yyyy-MM-dd HH:mm:ss')

The above expression will evaluate to the current date and time in EST, but if you try to copy and paste this into an action input it will just get input as text and the expression won’t evaluate at run time.

@{convertFromUtc(utcNow(),'Eastern Standard Time','yyyy-MM-dd HH:mm:ss')}

If you precede the same expression with the @ symbol and incase it in curly braces like above, then you’ll be able to copy and paste it as an expression into an action’s input.

Copy and Paste Dynamic Content or Expression Blocks

You can copy and paste dynamic content or expression blocks into a text editor or another action input.

Click on the content block and it will partially highlight blue. You can then press Ctrl + C to copy it to your clipboard then press Ctrl + V to paste into another action input or text editor.

Generate a URL for the Current Flow Run

There is no out of the box dynamic content for a link to the current flow run, but you can build one with the workflow() expression.

@{
concat(
	'https://us.flow.microsoft.com/manage/environments/',
	workflow()['tags']['environmentName'],
	'/flows/',
	workflow()['name'],
	'/runs/',
	workflow()['run']['name']
	)
}

The above expression will generate a URL that links to the current flow run.

This is a great option to add to any error handling notifications you build. This way you can include a direct link to the failed flow for quicker troubleshooting.

Use Compose Actions Instead of Variables

You should start using the Compose action for any static variables you define in your flow instead of the variable actions.

If you are not updating the variable in your flow after defining it, then Compose is a better option. They run faster, they can be grouped together inside scopes and you can put any data type or object in them.

Use Scopes to Group Actions

Power automate has a very useful action called a Scope. One of its uses is that you can add other actions inside it to help better organize large flows.

Above you can see a Scope action that contains 8 Compose actions.

This can be collapsed and the actions inside remain out of the way when you’re not working on them thereby freeing up valuable flow building real estate.

Enable Power Automate Experimental Features

If you’re the type that likes to try out the newest features right away then this tip is for you.

You can enable various preview features in power automate from the Power Automate settings.

Click on the settings icon in the top right corner of the power automate portal to open the settings and click on View all Power Automate settings.

In the settings pop up menu, set the Experimental Features toggle switch to On and then press Save.

Keep in mind these are experimental so they might change, break or disappear at any time as the warning says.

Format Numbers

If you try to use dynamic content of a numeric data type, you quickly realize they appear unformatted in places like emails, approval notifications or Teams messages.

You can format numbers in your flows very easily with a dedicated action for this.

Add the Format number action to your flow and then in the Number input you can add either a static number, number from dynamic content or an expression that evaluates to a number.

Then in the Format input, you can either choose a predefined format or enter your own custom format.

You can find full reference guides for either standard or custom number format strings which will work in the Format input. If you’ve ever used Excel custom number formats this will be very familiar to you.

(###) ###-####

For example, if you use the above custom format then the output will result in a 10 digit number getting a phone number like formatting.

formatNumber(1234567890, '(###) ###-####')

One thing to note is that you don’t actually need to use the dedicated action for this. The action is just a user friendly way of building an expression. The above expression would produce the same output as the action in the example.

Format Date and Times

There is not a dedicated action for formatting dates and times, but there is an expression.

formatDateTime('2021-03-17T21:30:15', 'D')

The above expression will return Wednesday, March 17, 2021 as the output. The second argument can be either a standard or custom date and time format string.

There isn’t an action to format dates and times like there is for numbers, but formatting can still be done using the Convert time zone action if you prefer to avoid expressions.

Set the Source time zone and Destination time zone equal and the time won’t be converted, but you will still be able to add formatting using the Format string option in the action.

Add Parallel Branches in Flows

Flows will run from top to bottom and by default will run in sequence.

But you can build flows with branches of action that run in parallel when those actions are not dependent on each other. This can greatly decrease the run time of your flows.

You can see three branches above. Each has an action that takes 5 seconds to run. If these were sequential it would add 15 seconds to the flow run time, but since they are running in parallel it will only add 5 seconds in total to the run time.

To add a parallel branch, click the plus icon between two actions then select the Add a parallel branch option. This will add the branch and let you select an action to add on the empty part of the branch.

Get Distinct Items with a Union Expression

Getting a list of unique or distinct items is a common data problem regardless of the tool or platform, so it’s a bit surprising there is no action for this.

The trick is you can achieve this with the union expression. Just take the union of an array with itself and this will result in only the unique items.

["A","B","B","C","B","A","C"]

The above array has been placed in a compose action and it contains repeated items.

@{union(outputs('Compose'),outputs('Compose'))}

You can then use the above expression, which takes the union of the array with itself, to get an array of the unique items.

["A","B","C"]

In this case the result will be the above array.

Apply to Each Concurrency Setting

The apply to each action allows you to perform actions for each item in an array. By default this is done sequentially for the items in your array.

You can speed this run time up quite significantly by running these actions concurrently.

Click on the three dots in your Apply to each action and then select Settings from the options.

Click on the toggle to turn On the Concurrency Control and then set the slider to set the Degree of Parallelism you want.

The Degree of Parallelism means how many steps will run at the same time. You can set this to a maximum of 50 runs. You might not be able to always crank this up to the maximum of 50 because of underlying API limits of the actions inside your apply to each step.

If your flow logic requires items to be processed in order, then enabling concurrency might not be feasible.

Peek Code

There is an option that will allow you to see the code behind the action.

Some inputs will use a friendly name in the UI so Peek Code can be quite handy when you want to see what value an input is actually using behind the scene.

Click on the three dots in the action and select the Peek Code option.

Here you can see an input labelled Calendar id and there is a friendly name for the input choices.

If you try and use this friendly input via some dynamic content or expression the action will fail because this is not actually the id used behind the scene.

Using the Peek Code option you can see the real id is a long text string.

Use the ? Character to Reference Items in an Object

You might have noticed sometimes there are question mark characters in expressions. What does it do?

In this example, the GivenName does not exist in the object it is referencing. Adding the question mark character (?) to the reference will ensure the Get Given Name action does not fail and instead returns a null value.

Set a Custom Action Time Out Duration

Flows have a maximum run time of 30 days at which point the flow will stop and no remaining actions will execute.

This can be a problem if you’re building approval processes in power automate where users might not respond within this limit. No error handling actions you add to your flow will execute if the flow fails due to a 30 day time out.

To ensure your error handling still has time to execute after an approval action times out, you can set the approval action to time out before the 30 day limit.

Click on the three dot of the action then choose Settings then enter the custom time out Duration in ISO 8601 format.

P5DT13H17M20S

For example, the above ISO 8601 duration format represents a duration of 5 days, 13 hours, 17 minutes and 20 seconds.

Trigger Conditions

It might be that you only want a flow to run under certain conditions. For example, maybe you have a flow that is triggered when an item in a SharePoint list is modified, but you only want this flow to run when the Status field in the list is set to Closed.

You could use a condition action inside the flow to test this field value and perform actions accordingly, but this would waste flow runs. A much better option is to use trigger conditions so the flow never runs when the conditions are not met.

Click on the three dots in your trigger action then select Settings from the options.

Under the Trigger Conditions section click on Add then enter your expression and press the Done button. The flow will only run when your expression evaluates to true.

@equals(triggerOutputs()?['body/Status/Value'],'Closed')

In the example using the above expression, the flow will only run when the Status field has a value of Closed.

Unfortunately, there is no expression builder in the trigger settings, so it’s best to use a Compose action after your trigger to build your expression. This way, you will have access to the expression intellisense and dynamic content menu. Then you can copy and paste this into the Trigger Conditions in the settings.

Make sure your expression starts with the @ character. This is required in the trigger condition input to tell Power Automate the text is an expression.

Add Error Handling with Configure Run After

Actions will fail occasionally for a variety of reasons, this is a fact that you need to account for in your flow design. Fortunately there are options to define what happens after an action fails.

For the action you want to configure click on the three dots and select the Configure run after option.

This will then let you pick one or more options for when the action should run.

  • Run the action when the previous action is successful.
  • Run the action when the previous action has failed.
  • Run the action when the previous action is skipped.
  • Run the action when the previous action has timed out.

In this example the action is set to run when the Create Quote Documents action fails and will not be executed otherwise. Here the actions are Scopes which is a great way to define when groups of actions will run.

If any action inside the Create Quote Documents Scope fails, then the entire Scope is considered to have failed and all actions inside the Flow Failure Scope will run.

Conclusions

There are a lot of hidden tricks in Power Automate.

Knowing them will help you save time and allow you to build better flows.

Did I miss your favourite Power Automate tip? Let me know it in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

6 Comments

  1. Crispo Mwangi

    Great list…I have learned something new.

    One tip you have missed is how to delete powerapps unnecessary Parameter variables…just delete powerapps trigger and add it again

    Reply
    • John MacDougall

      Yes, it’s a necessary evil sometimes.

      PS, you’re the first comment on my new blog! Congrats 🥳 No prize for it though 😂

      Reply
  2. Sudhi Ramamurthy

    Had no idea one could copy/paste actions as text/json. Thanks a lot!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Get The Latest News

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest tech!