How to retrieve a user’s timezone from DataVerse in a Power Automate flow

Hello everyone and welcome to my blog. In today’s blog, I will show you on how to get the timezone details of a user from DataVerse in a Power Automate flow.

Before we get started with the Power Automate flow, it’s important to understand the tables in DataVerse which we will use in the Power Automate flow.

The first table is ‘User Settings‘. First we query this table to fetch the timezone code for a user.

The next table is ‘Time Zone Definitions‘ where we will pass the timezone code get the name of the timezone. So let’s get started.

I am using flow with Manual trigger. But the steps I will discuss here you can basically use with any type of flows. I start with input as the user email.

As a next step I will query the User Settings table to fetch the timezonecode for the user. For this I use the ‘List Rows‘ action of DataVerse and use the following FetchXml query.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="usersettings">
    <attribute name="timezonecode" />
    <link-entity name="systemuser" from="systemuserid" to="systemuserid" link-type="inner" alias="aa">
      <filter type="and">
        <condition attribute="internalemailaddress" operator="eq" value="<user email>" />
      </filter>
    </link-entity>
  </entity>
</fetch>

As you can see in the above screenshot, I have used the UserEmail variable from earlier step. The next step is to get the timezonecode of the user. I will use a variable to store the value of timezonecode.

Below is my flow component to get the timezonecode from the results.

If you look at the screenshots, it’s quite simple. I have a variable and then I set the variable from the output of the previous action. I had to use apply_to_each and this is because I have used the List Rows action in the previous step which always return a collection.

So now I have the timezonecode value. What’s next? If you remember at the very beginning of the post I talked about another table – Time Zone Definitions.

This is the table I will query to give me the name of the TimeZone name from Timezonecode. And below is the flow construct to do the same.

Quite simple isn’t it? All we are doing is to use the timezonecode to query the Time Zone Definitions table and get the Standard name. Below is the fetchXml I have used in the flow step.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="timezonedefinition">
    <attribute name="standardname" />
    <filter type="and">
        <condition attribute="timezonecode" operator="eq" value="[timezonecode]" />
     </filter>
  </entity>
</fetch>

And then again the usual step of retrieving the TimeZone name from the resultset.

And below is the output when I run the flow. As you can see, I now have the timezone name.

That concludes this post. Hope you liked the post. If this post has helped you, you can buy me a coffee.

To stay updated with more such tips on Microsoft.NET and Power Platform, please subscribe to my blog. Link to subscribe on the right pane.

Debajit Dutta
Business Solutions MVP