Power Community

Power Community

Set Timezone format field based on Account Location in Microsoft Dynamics 365

http://www.inogic.com/blog/wp-content/uploads/2022/11/1Map-Dynamics-365.jpeg

In Dynamics 365, we have the flexibility to store data of a variety of types such as text, number, lookups, options, etc. Time Zone is a type of format for Whole Number, which allows the user to store the Time zone information of a particular record in CRM.

The screenshot below explains the same

Map Dynamics 365

In this blog, we will consider a business requirement where we have to set the Time Zone field value on an Account based on the Latitude and Longitude values dynamically when the Account record is created in CRM.

Let’s walk through the steps we need to perform to achieve the above requirement:

1. Navigate to https://make.powerapps.com and create a custom field “Account Time Zone” with data type as Whole Number having the format as TimeZone. Add the field on the form as well so that the user can see the value in the field.

2. We will create a Power Automate Flow to get the timezone from Location coordinates and set the TimeZone field value on the Account record. Navigate to the appropriate solution and create a Power Automate flow with trigger action as “Add a Row”.

Refer the screenshot below-

Map Dynamics 365

3. Add HTTP connector to get the Time Zone from Latitude and Longitude field value of Account.

Map Dynamics 365

As shown in the screenshot below, add a URI as follows:

https://dev.virtualearth.net/REST/v1/TimeZone/@{triggerOutputs()?[‘body/address1_latitude’]},@{triggerOutputs()?[‘body/address1_longitude’]}?key={BingMapKey}

  • @{triggerOutputs()?[‘body/address1_latitude’]} : will be address1_latitude field value of the Account.
  • @{triggerOutputs()?[‘body/ address1_longitude ‘]} : will be address1_longitude field value of the Account.

4. Next step will be getting Response from the HTTP body as shown in the below screenshot.

Map Dynamics 365

5. Now add a step to Initialize the Variable with the below expression value:

body(‘Http’)?.resourceSets[0]?.resources[0]?.timeZone.genericName

This expression will get the Generic Name of the Time Zone as follows-

Map Dynamics 365

6. Now we will retrieve the Time Zone Definitions record based on the Generic Name with the “Time Zone Code” column.

Map Dynamics 365

  • Select Columns: timezonecode
  • Filter rows: standardname eq ‘@{variables(‘Time Zone Name’)}’

7. Once we get the Timezone code, we will set the appropriate Time Zone on the Account within the “Account Time Zone” column.

Note that the Time Zone format field stores an integer value that same as that of the Time Zone Code from the OOB Time Zone Definitions table in CRM.

 So, will add a step to Update an Account with Account Time Zone column = Time Zone Code retrieved from the previous step.

Refer to the below screenshot

Map Dynamics 365

8. Save the Flow and now, we can test the flow by creating an Account record with the appropriate Latitude and Longitude.

Map Dynamics 365

9. Refresh the Account form as the Power Automate Flow will be triggered in the background and will take some time to complete the process. Now we can see the Time Zone has been set on the Account.

The screenshot below supports the same-

Map Dynamics 365

Conclusion

In this way, we can set the dynamic value in the Time Zone based on the Time Zone Code retrieved using latitude and longitude attributes.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

ChatGPT – Insights

Hi Folks, In this modern era where AI/ML is ruling the world and automating all the possible day to day...

More Articles Like This

- Advertisement -spot_img