Friday, 23 July 2021

5 Tips & Trick with Power Automate Cloud Flows

On Tuesday July 13, 2021 I shared five tips and tricks with Power Automate Cloud Flows at my former Melbourne BusApps, D365 & Power Platform user group.

In this WTF episode I shared what these five tips and tricks are so that you can learn about them too in your own time 😊

1. Naming your connection references

When you use add an action and if it's the first action to be added for that connector, as the flow maker you are usually signed in automatically which is what is used as the connection for the connector. Your credentials is used for the authentication.

Below is an example where I have added a Microsoft Dataverse action from the Microsoft Dataverse connector and I am immediately signed in.

In the WTF episode I talked about how it will automatically use the name of the connector as the Default Name value for the connection reference. In this scenario, it will appear as Microsoft Dataverse.

Even if you create a new connection from within the action, the same behaviour will appear as demonstrated in the WTF episode where the newly created connection reference will appear as Microsoft Dataverse.

How to name your connection reference

Head over to your solution and add a new connection reference. In the side panel that appears 
  1. Enter your desired name in the Display name field
  2. Provide a description
  3. Choose a connector. In my scenario it is Microsoft Dataverse
  4. Choose your credentials as the Connection
  5. Click Create
The newly created connection reference will appear in your solution.

When you view the connections in the action back in the cloud flow, you'll now see the named connection reference.

2. Create HTML table action #hack

If you try inserting a space in a header value when using the Create HTML table action, it won't work. In my scenario my header value I needed to enter was "Case Number" but when you hit the space bar on your keyboard, the space will not be rendered. The value will appear as "CaseNumber" instead.

How to insert a space in the header value

The hack I found was buried in a Power Automate community forum post. Open Notepad and type in your value, then copy and paste. That's it! Totally works.

3. Pieter's method for Apply to Each

There may be some use cases where you need to grab values from records or rows returned in an Apply to Each action to use them downstream in the cloud flow. The use case I mentioned in my WTF episode was about looping through the Cases to retrieve the fullname of the Owner so that it can be used in a notification for high priority cases.

Typically what has been done by flow makers (including myself in the past) is to 
  1. Have an Initialize Variable action before the Apply to Each which acts as the array variable
    1. In my WTF example I used this to form an array of the fullname values
  2. Within the Apply to Each have an Append to Array Variable action which grabs the fullnames of the Owner from each Case which is then surfaced up into the array variable (No.1)
  3. Any action downstream in the cloud flow can then use the array variable (No.1)

The infamous Pieter's method

Pieter's shared a blog post about what he discovered where variables are not used and that you can display your looped values as an array outside of the Apply to Each action. Couple of tricks here with a bonus tip.

Within the Apply to Each action, have a Compose action that will retrieve the value you're after. In my use case it was the fullname of the Owner associated to the high priority Case.

After this Compose action, add a new Compose action that references the output. Then, using the "Peek Code" feature, copy the expression.

Below the Apply to Each action or anywhere else downstream in the cloud flow, you can use the copied expression. I used a Compose action and copied the value to demonstrate that the fullname values were correctly retrieved

You'll notice however that it displays it as an array and will show duplicate values of the fullnames. This is because it grabbed all fullname values from all the Cases as expected. 

What if we only need to see the fullnames once, in other words the distinct values?


  1. To only display the distinct values, use the union function.
  2. To display the returned distinct values as a single string rather than an array, use the join function.
What's cool about the join function is that it is one smart cookie! 🍪 
The join function knows that after the last row in the array, it will not insert the delimiter you have defined in your expression. In my WTF episode use case, the expression was

join(union(variables('Fullnames'), variables('Fullnames')), ', ')

My defined delimiter is a comma and a space.

The cloud flow this time round will now display the array as string with distinct values only. No more duplicate fullname values 👍🏼 and also notice who there's no comma and a space after the last row/fullname. Told you the join function is one smart cookie 😁

4. Custom date and time formats

When you want to move away from the standard date and time formats, you can easily use a custom date and time format. This is useful when you want to have a particular format for uses cases that require a notification to be posted on Microsoft Teams in a channel or via email. 

Refer to the documentation for the format specifiers

The documentation has been updated and outlines the different format specifiers.

For example the first format specifier, d, is displaying dates that have a day of 1 to 9 as a single integer value without a leading zero so it will appear as 1, 2, 3 and so forth.

The second format specifier in the document, dd, is displaying dates that have a day of 1 to 9 with a leading zero so it will appear as 01, 02, 03 and so forth.

In my use case in the WTF episode I wanted the date and time to display as the following

Sun Jul 18 03:00 PM

The format I used in my expression is the following

ddd MMM dd hh:mm tt

I also explained that I was using the convertFromUtc function in my expression as Microsoft Dataverse, like other systems, store date and time as UTC. If you use the value as-is from Microsoft Dataverse it will be in UTC. I therefore used the function to convert the UTC value into New Zealand local time. My expression is the following

convertFromUtc(triggerOutputs()?['body/createdon'], 'New Zealand Standard Time', 'ddd MMM dd hh:mm tt')

If you want to dynamically reference the timezone value because let's say you're in a country where there are multiple timezones, I got you! I covered this in previous WTF episodes
  • How to identify a Contacts' time zone in Flow using CDS and Bing Maps
    • This covers how to get a Contacts' time zone so that you can format the date to their local time. This is useful for external communications.
  • How to populate a date and time field based on a user's local time zone
    • This covers how to get the user's time zone so that you can format the date to their local time. This is useful for internal communications amongst the user's who have access to Microsoft Dataverse.
    • Note: This would only work if the communication is sent to a single person. In the scenario where it is sent to a group of users who may be in different timezones, then the suggestion here is to make a reference to the timezone such as "Sun Jul 18 03:00PM NZST"

5. Dataverse trigger condition

I covered this in my last WTF episode and this time round the use case is different to demonstrate how trigger conditions for the Microsoft Dataverse connector can be applied.

The example I gave in this WTF episode is about triggering the cloud flow only if the customer associated to the Case is an Account. The customer column is special where it can have two types - Account or Contact.

In the scenario where the customer column value is a Contact, the cloud flow should not trigger.

The trick

For every trigger in cloud flows, there will always be a response/output provided. The trigger in my cloud flow is the "When a row is added, modified or deleted." In the run history of a cloud flow that succeeded, you can review the outputs.

If you scroll down you'll see a property of 


Copy this property and in the edit mode of the cloud flow, 
  1. Click on the ellipsis (. . .)
  2. Navigate to Settings
  3. Enter an expression in the Trigger Conditions

The expression I used is

@equals(triggerBody()?['_customerid_type'], 'accounts')

This expression references the property and therefore the condition is that the property of  must equal accounts.

The cloud flow will now only trigger when the customer associated to the Case is an Account, and not a Contact.

If you want to learn how to do AND OR statements in your condition refer to my second WTF episode #2018Throwback 

What I shared in WTF Episode 2 is in reference to the deprecated Condition action which is no longer available but the same principles apply to the trigger conditions in the Settings of the trigger for the Cloud Flow.


These were the 5 tips and tricks I shared in the user group session. 
  1. Create the connection reference in a solution in order to enter a named connection reference
  2. Use Notepad and copy + paste your value for the Header into your Create HTML table action to have a space in the Header value
  3. Outside of the Apply to each action reference the output of the Compose action within the Apply to each action and use a couple of functions to display the array as a string
    1. Union - to retrieve only the distinct values in the array
    2. Join - to display the distinct values from the array as a single string
  4. Refer to the Power Automate Cloud Flow documentation to format the desired custom date and time value
  5. Use the Microsoft Dataverse trigger conditions under Settings to enter an expression that references the properties in the body of the trigger
Awesome sauce. I hope you learnt something new and thanks for stopping by 😄


Post a Comment