How to create Dynamics 365 Scheduled Report using Microsoft Flow?

Learn how to create Dynamics 365 Scheduled Report using Microsoft Flow. Microsoft released Flow about a year and a half ago, and it has seen significant upgrades since then. We can use flow to schedule a report and also include an HTML table in the email body.
Before we consider the solution, we might need to look at the platform that we are working on right now. Microsoft Business Application Platform, where Dynamics 365 plays an integral part in it, comes with Microsoft Flow that has numerous connectors available. This opens a very broad capability in building the business workflow.

Step 1:  To set the schedule of the Flow
Dynamics 365 Scheduled Report

Step2:  To filter Opportunity data Initialize variable.
Dynamics 365 Scheduled Report

To get the created on = Last 7 Days, we could use the Flow Built-In Formula/Expression:
Dynamics 365 Scheduled Report

Step 3:  Next, we need to construct the filter for the Get List of Records from Dynamics 365 Fetch XML Query.
Dynamics 365 Scheduled Report

Step 4: Once we have the list record, we can use the Create HTML Table action on Flow to create the HTML table for the email body, as well as some field mapping.
Microsoft Flow Report1

Step 5: Before submitting the file, use the compose action to add CSS to the table to make it more appealing.
Microsoft Flow Report2

The table is now looking more appealing by using CSS.
Microsoft Flow Report3

Step 6:  By producing HTML and converting the file to PDF, you can create and save PDF files using OneDrive operations:
Microsoft Flow Report4

Step 7: Typically, you could create a folder in OneDrive to store the report temporarily and do periodic clean-up. Then, put the content you want in the email body and attach it.
Microsoft Flow Report5

As a result, the following email with a PDF attachment is generated:
Microsoft Flow Report6

Step 8:  The following report and PDF file are received in Outlook:
Microsoft Flow Report7

PDF file is opened with PDF reader as below:
Microsoft Flow Report8

Step 9: This is what the final flow looks like:
Microsoft Flow Report9

Leave a Reply