Use List Records in Power Automate Flow to Create and Send CDS Report Data

9 Comments

List Records is an action in the Common Data Service connector in Power Automate Flow that lists records based on a query you provide to the Common Data Service. The results can then be sent somewhere, such as in an email or posted to a Microsoft Teams chat. In this post, we will look at how to use List Records to do both these things.

If you prefer video, check out my YouTube video on how to do this:

First, log into https://flow.microsoft.com and create an Instant flow:

We will run it on pressing a button in Power Automate by using the Manually Trigger a Flow trigger:

We see below. Click + New Step:

Find Common Data Service and select List Records:

Choose your Environment and Entity Name. We will select the Accounts entity so we can create a report of accounts from our Common Data Service / Dynamics 365 environment:

Selecting Advanced Options, we see we can add additional criteria to our request, such as filtering, ordering, top count, and expand query:

Let’s save this:

And test the flow:

Go to the Flow Runs Page:

We see the flow ran successfully. Let’s look and the output. Click to Download:

We see we get a JSON output file:

Let’s make something more user-friendly. Let’s convert this output to an HTML table:

Save and run this:

We see in the output we’re now getting HTML:

Now instead of all columns, let’s order by the Account Name and only display that in the HTML:

Rerun the flow. We see a nice HTML table now produced with one column:

Now let’s filter even more and get the top 10 accounts by revenue, ordered descending:

And display the revenue as well:

We see a nice output in the body:

Now that we have this, we will want to do something with it. First, let’s create an email to send with this data. Add the Send an Email action from the Office 365 Outlook connector:

We will add the output to the body of the email:

On running this, we see our email output. Very useful if we want a report that can be run easily through flow:

Finally, let’s post this to Microsoft Teams:

Select Post a Message:

Add the Output to the Message:

Run the Flow. We now see the message in Teams when we run the Flow!

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

9 Responses to Use List Records in Power Automate Flow to Create and Send CDS Report Data

  1. Hi Carl,
    This has been useful for my use case, however i’m stuck on including Lookup Field labels in the HTML Table.
    How would you go about getting the Owner Name of the Accounts listing in your email?

      • but the field does not show later to access the field from the expansion, is there any function we could use for this, i am trying to create an html query from opportunities that includes the customer name.

  2. Hi Carl, I am using “FetchXML” to group by the Contacts per status, but get error.
    The xml only allows to groupby contactid, and is the following:

    The result:
    ——Contact Id——StateCode
    AAedcf55-df22-eb11-a813-000d3a361686 —- 1
    bbbbbbbb-df22-eb11-a813-000d3a361686 —- 1

    Grouping by ‘statecode’ there is an error.
    How can I group by in fetchxml for Power Automate Flow? to get this:
    ——Contact Id——StateCode
    ——3——————-1
    ——4——————-0

    Thanks and best regards.

  3. Is it possible to generate and send this report as an excel or CSV similar to export data feature on CRM Grid View?

    • Hello, did you find an answer to this? My inquiry also is about exporting to excel rather than providing a list.

  4. Hi,

    the “common data service” is not available in my instance of dynamics 365/power automate. what is the prerequisite to having that action available?

Leave a Reply

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