Get the local trigger time in Power Automate Microsoft Office 365 local time

What’s the time a flow was triggered locally to the user who triggered a flow? How do we get the local trigger time?

Standard Time

When you create a flow that is triggered by the creation of a record inn Microsoft Dataverse, you might find that the Creation time doesn’t match your actual time.

In my example below I created a new record at 10:16 am and the Created On time in my When a row is added, modified or deleted trigger tells me that it was created at 9:16

Get the local trigger time in Power Automate Microsoft Office 365 mismatch in created time

Whatever the timezone is used by the data, it may not match the tiemzone fo the user. So how do we get the time locally to the person triggering the flow.

Finding the user

First steps first, we need to find out who the user is that triggered the flow by adding a new account to my Dataverse database.

to get the user you can use the Get a row by ID action.

Get the local trigger time in Power Automate Microsoft Office 365 image 14

This will give you the details of the user, but not their timezone!

For the timezone we will have to call Microsoft Graph.

Get the timezone

To get the timezone used by the user I’m going to look at the Mailbox settings.

https://graph.microsoft.com/v1.0/users/@{outputs('Get_a_row_by_ID')?['body/internalemailaddress']}/mailboxSettings

If you are really worried about collecting too much information you could also use the following endpoint instead:



https://graph.microsoft.com/v1.0/users/@{outputs('Get_a_row_by_ID')?['body/internalemailaddress']}/mailboxSettings/timeZone

The above endpoints will collect the following setting in your Outlook:

Get the local trigger time in Power Automate Microsoft Office 365 image 15

Using the endpoints in a flow in Power Automate

To use the end point an HTTP action will need to be added to our flow that we created so far. If you need any more information on how to create an app registration in Azure then please look at my post create a Microsoft Teams team template.

The only difference is that you will need to give consent to use the following permissions in your app :

  • MailboxSettings.Read
  • MailboxSettings.ReadWrite
Get the local trigger time in Power Automate Microsoft Office 365 image 16

And all the information returned by the above HTTP action and collected with two Compose actions:

Get the local trigger time in Power Automate Microsoft Office 365 image 17

The expression in the first Compsoe is:

body('HTTP')?['timeZone']

And the second one is (this can be selected from Dynamic content as well):

triggerBody()?[‘createdon’]

Get the local trigger time

So we are now nearly there.

We have a time to convert and we have a time zone to convert to. Using the ConvertFromUTC function it is now possible to get the actual time matching the local trigger time when the user created a new record:

convertFromUtc(outputs('time'), outputs('timeZone'),'yyyy/MM/dd hh:mm')

In the above code there are of course other date formatting options possible. Please look at my formatDateTime posts fro more details on that.

Get the local trigger time in Power Automate Microsoft Office 365 converrt local trigger time

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading