Power Automate: Convert UTC to Specific User Time Zone

We are getting the requirement to convert the UTC (Dataverse Default) to the specific user time zone very frequently. We used to write a plugin for this scenario, but now Power Automate has a perfect UI with less coding.

Use Case

Create new email activity when the phone call is generated.

Use Case Explanation

You may wonder phone call is an activity then why do we need to create another duplicate activity. The real use case is, that one of the Senior members should be notified whenever he is part of that account. Just think of the relation

Phone Call Recipient is Contact –> Contact has relation to Account –> Account has to list of Team members (Senior member is part of the team member)

Power automation is the right tool to get it done. Before Power automate, we used to write plugins for these kinds of scenarios.

Description

In this example, we are using Dataverse to create new email activity when a new phone call is created or the recipient is updated.

Note: Click the image to view larger 

Overall Steps

  1. Initialize User Email
  2. Get User Id (System User Id)
  3. List User Settings (For this User)
  4. Get User Time Zone Definitions (Name)
  5. Create Email Message
  6. Send Email Messages using  Perform an action

Complete Flow

All the steps in detail

  1. Trigger and Initialize user email

[
{
“participationtypemask”: 1,
“partyid@odata.bind”: “queues(from Queue GUID or any  mail box enabled with email)”
}
]

2. Get User Id (System User Id)

<fetch>
<entity name=”systemuser”>
<attribute name=”systemuserid” />
<attribute name=”fullname” />
<filter>
<condition attribute=”internalemailaddress” operator=”eq” value=”@{variables(‘User Email’)}” />
</filter>
</entity>
</fetch>

Extract Id and Add to Recipient

3. Get User List Settings

<fetch>
<entity name=”usersettings”>
<attribute name=”timezonecode” />
<filter>
<condition attribute=”systemuserid” operator=”eq” value=”@{variables(‘User Id’)}” />
</filter>
</entity>
</fetch>

4. Get User Time Zone Definitions

<fetch>
<entity name=”timezonedefinition”>
<attribute name=”standardname” />
<filter>
<condition attribute=”timezonecode” operator=”eq” value=”@{variables(‘User Time Zone Code’)}” />
</filter>
</entity>
</fetch>

5. Create an Email Message

convertFromUtc(triggerOutputs()?[‘body/scheduledend’],variables(‘Time Zone Name’),’MM/dd/yyyy hh:mm tt’)

6. Send an Email Message

Testing

Create Phone Call

Output (Email Actitiy Created) with due date converted to user time zone.

In this case, the UTC time zone converted to the user (John) time zone which is the Eastern Time Zone.

 

Conclusion

In this case, the UTC time zone converted to the user (John) time zone which is the Eastern Time Zone.

  • Phone Call Created with Due Date: 05/11/2022 9:30 AM (Central Standard Time)
  • Email Activity Created with Details: 05/11/2022 10:30 AM (Eastern Standard Time)

Leave a Reply

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