FormatDateTime function in a Flow | Power Automate

DateTime fields from Dataverse / Common Data Service (Current Environment) are retrieved in full Date and Time format. And in common applications, you are required to only retrieve the Date and not the Time. Or even Format the Date Time in a certain way.

Let’s look at how to format DateTime in a Flow which appears as below

Let’s look at a simple example by trying to format a Created On date field.

FormatDateTime function

  1. Let’s a take a variable of type String to store our formatted Date. Now, in the variable, go for Functions and look for FormatDateTime function.


  2. Now, it asks for 2 parameters – TimeStamp and Format.

  3. Since I’m picking the field from the trigger itself, I’ll use the below formula to pick from triggerBody().

    In case you want to also learn how to use triggerBody(), triggerOutputs() or outputs(), you can refer below posts –
    1. Using triggerBody() / triggerOutput() to read CDS trigger metadata attributes in a Flow | Power Automate
    2. Using outputs() function and JSON Parse to read data from missing dynamic value in a Flow | Power Automate

  4. In the second parameter, put the format of the date in single quotations as shown below –


    You can follow this official Microsoft documentation – https://docs.microsoft.com/en-gb/dotnet/standard/base-types/custom-date-and-time-format-strings?WT.mc_id=DX-MVP-5003911

  5. And your Date Format is set. When you run the Flow, you’ll get the formatted date.


    Hope this was quick and helpful!

Here are some more Power Automate / Flow posts you might like to check –

  1. Formatting Approvals’ Details in Cloud Flows | Power Automate
  2. Number Formatting in a Flow | Power Automate
  3. Parallel Branching in Cloud Flows – Isolate Response dependent Step Actions in parallel branches | Quick Tip
  4. Trigger Conditions not working in a Cloud Flow? Here’s Why | Power Automate Quick Tip
  5. InvalidWorkflowTriggerName or InvalidWorkflowRunActionName error in saving Cloud Flows | Power Automate Quick Tip
  6. Read OptionSet Labels from CDS/Dataverse Triggers or Action Steps in a Flow | Power Automate
  7. Run As context in CDS (Current Environment) Flow Trigger | Power Automate
  8. Setting Lookup in a Flow CDS Connector: Classic vs. Current Environment connector | Power Automate Quick Tip
  9. Make On-Demand Flow to show up in Dynamics 365 | Power Automate
  10. Task Completion reminder using Flow Bot in Microsoft Teams | Power Automate

Thank you!!

Rating Control to represent data from Dataverse in a Canvas Power App | Power Platform

Although, you can use Text based controls to represent data as is in a Canvas Power App. So why not go an extra mile to make it look more intuitive.

Scenario

Let’s say there are Accounts and you have some kind of Compliance Ratings on them to represent compliant they are based on certain criteria. Could be a Numeric value or Decimal value. But Rating Control represents only in Numeric i.e. Whole Numbers.

So, for this example, I’m using a Rating field which is of type Whole Number in Dynamics 365 on Account entity.

And the complete Dataset looks like this in Dynamics 365 / Dataverse.

Note: I tried with Decimal but it rounded the values hence, sticking to Whole Number.

Rating Control

  1. Let’s say below is the Gallery and you want to show Ratings in the form of stars instead of traditional numeric values.

  2. Now, let’s use Rating Control below the Names of the Accounts to show the Rating values. Select the first Row once you connect to the Common Data Service i.e. CDS / Dataverse Data Source and select the entity you want to populate it with. In this example, we are using Accounts. So my Gallery is populated with Accounts records.
    Select the first record and navigate to Insert tab and look for Input controls as shown below


    Now, look for Rating control.

  3. Once you select Rating, it’ll appear iteratively since it’ll be applied “For Each” of these records in your Gallery control.


  4. I’ve just rearranged them under the name to make them look proper.

  5. Let’s make it Read Only by changing the behavior, so that the Users don’t accidently touch and set a value during Runtime. Although, this won’t affect the actual data but the representation will be incorrect in that case.

  6. Also, the Max will represent the length of your Rating whereas the Default value are kept to 0 in case the field value is not set at Source. (I think 1 would still be misrepresenting)

  7. Now, I’ll connect this Control to the Data Source’s field i.e. Rating field on the Account entity that represents the Rating value.
    On the Default, I’m setting ThisItem.Rating where ThisItem represents the Row of the Account i.e. the Account record itself and Rating is the field in Dynamics 365’s Account entity which we saw in the scenario above.


  8. And that’s it. You can Save and Publish your App and Run it.

Rating values

Now that we’ve added the Rating Control, let’s Run our App and see how it represents the data from your Accounts entity.

And the Ratings represent the below data –

Hope this was useful!

Here are some more Canvas Power Apps posts you might want to check –

  1. Clear a field value & Reset Form in a Canvas Power App [Quick Tip]
  2. Get Dynamics 365 field metadata in a Canvas App using DataSourceInfo function | Common Data Service
  3. Debug Published Canvas Power App with other users using Monitor | Power Platform
  4. Download a File from a Canvas Power App using a button | Power Platform
  5. AddColumns() function to dynamically add columns to a Data table in Canvas Power App | SharePoint List
  6. Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform
  7. Implement character length validation in a Canvas Power App | Power Platform
  8. Log Canvas Power App telemetry data in Azure Application Insights | Power Apps
  9. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  10. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  11. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  12. Restore older version of a Canvas Power App | Power Platform

Thank you!!

Setting Lookup in a Flow CDS Connector: Classic vs. Current Environment connector | Power Automate Quick Tip

Both the CDS and CDS Current Environment connector are similar yet different in the way how they accept Lookup values set in their Update a record steps.

Here’s a quick tip!!

Scenario

Taking a simple example of setting Primary Contact Lookup on Account.

We’ll do the same thing using both the connectors mentioned below.

Common Data Service connector

Common Data Service (Current Environment) connector

Common Data Service Connector

Let’s start with using the classic Connector first –

  1. As mentioned in the Scenario above, let’s first try to use a class Common Data Service connector. Here’s how you identify the same.

  2. Now, whenever you have to set the Lookup value in the classic connector’s Update a record action, you can simply tag the Primary Key as is on the field in the connector step as shown below.


    And lookup can be tagged very easily.

Common Data Service (Current Environment) Connector

  1. Let’s do it with the new Common Data Service (Current Environment) connector. This is a much simpler way to tag a Lookup. Now, the new CDS Current Environment connector can be identified as below.

  2. In order to set Lookup, you’ll need to patch is in the below way
    pluralNameOfTheEntity([PrimaryKey])

  3. Here’s how my friend Linn Zaw Winn’s post explains in details of why we have to choose the plural name and exactly where you can get it from – http://linnzawwin.blogspot.com/2019/11/power-automate-how-to-set-lookup-field.html

Hope this was useful. Here are some more Power Automate / CDS posts which you might want to check out –

  1. Using outputs() function and JSON Parse to read data from missing dynamic value in a Flow | Power Automate
  2. Adaptive Cards for Outlook Actionable Messages using Power Automate | Power Platform
  3. Make On-Demand Flow to show up in Dynamics 365 | Power Automate
  4. Task Completion reminder using Flow Bot in Microsoft Teams | Power Automate
  5. Run As context in CDS (Current Environment) Flow Trigger | Power Automate
  6. BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
  7. Accept HTTP Requests in a Flow and send Response back | Power Automate
  8. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  9. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  10. Adaptive Cards for Outlook Actionable Messages using Power Automate | Power Platform

Thank you!!