Search
  • Dynavigate

Flow and date formats

Updated: May 20, 2019

Showing data in a format that users understand is important and displaying so they can take the correct action is vital.

Default for flow is to use data data from Common Data Service (CDS) and display dates in UTC using this pattern: "yyyy-MM-ddTHH:mm:ssZ" example like this:

"2019-02-13T08:30:10Z" and this is not very user friendly and there are not many users using UTC (especially during daylight savings time), so the time is wrong as well.

Here we will show you how to display one field in the correct format and the correct time zone.

Go to https://flow.microsoft.com and then choose an environment that has CDS:


Select envionment

First off, this solution is base on that you have are using one of the Dynamics 365 Customer Engagement Apps, like sale, this allows users to have personal settings in the first place.

Consider that you want to show the modified on date as the users who did the modification.

Format date flow, final result

So when a record is update (or created, the trigger "when a record is update" will trigger for both) we will run this. First get the settings for the user who did the update:


Format flow, get user settings

Note this name is set to "Get User Settings" I will use this name in a formula later on.

Unfortunately the user settings does not have a good name for the time zone, so we have to get the name, here we have to get a list, even when we have just a list of 1 records, and we will make sure about that and set the top count to 1:

format flow, list time zone definitions

Next up is using the user settings and produce some useful stings:


format flow, format date and time

This is just two "Compose" actions with one line in each of them:

replace(body('Get_User_Settings')?['dateformatstring'],'/',body('Get_User_Settings')?['dateseparator'])

replace(body('Get_User_Settings')?['timeformatstring'],':',body('Get_User_Settings')?['timeseparator'])

Now its time to find a "Convert time zone" action and add it, (no don't add the for each, that will be added once you add the field "standard name".

Note also that the modified on, is the "when a record is update" otherwise we get a field from other entities.


format flow, convert time zone

Base time, is then the "modified on" for the updated record, format string is the output from the date format + output from the time format (this can allow me to use the same approach if I ever want a solution using date only or time only fields.

Source time zone is always UTC, and Destination time zone is the output from the list of time zone definitions.


Done, we got everything that we need to convert one date time field, now we can reuse everything and just add "Convert time zone" actions for each field that we need converted.

22 views

Visiting adress:

 

Dynavigate AB

c/o XLENT

Baltzargatan 25, 2nd floor

211 35 Malmö

Postal adress:

 

Dynavigate AB

c/o Gynnerstedt
Östra Lärkvägen 7
236 42 Höllviken

 

 

Tel:         +46 709 851940

Org.No:   559156-9818