Microsoft Flow: Creating Dynamics 365 Scheduled Report – Low Code Approach

Recently I’ve been exploring the power of Microsoft Business Application Platform. One of the most common requirements that I think we can solve in the Low Code Approach is the scheduled report.

For this example, I’m going to use this example user story to describe the scheduled report requirement: As a sales manager, I want to receive a daily digest of the new opportunities, so that I have the visibility of new opportunities in my organisation.

Before thinking about 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 up a very broad capability in building the business workflow.

So, without further ado, here is my “Low-Code” approach generating the scheduled report (if you want the more complex one using SSRS, Bob Guidinger, has the solution here).

The first step in the Flow is to set the schedule:

Recurrence_Step.png

Next, we need to construct the filter for the Get List of Records from Dynamics 365 oData query, to build it I’m using Jason Lattimer’s CRM Rest Builder 

Filter_Builder.png

Once the query is generated, copy the filter as the base to be put in Flow

Filter-Copy.png

To get the created on = yesterday, we could use the Flow Built-In Formula/Expression:

List_Records.png

You also could try the query whether it’s successful or not by running the Test process on Flow

Test_Result.png

This will need a bit of Dev knowledge to understand the JSON output of the list records, but we can confirm that it is returning the list correctly or not

Testing_on_the_List_Records.png

Once confirmed, then we can construct the HTML table for the email body using the Create HTML Table action on Flow and to some field mapping.

Create_HTML_Table.png

And then send the email action:

Send_email_v1.png

Make sure that to select the Is HTML to Yes, otherwise, the HTML tags will be rendered as literal text

Is_HTML.png

This will produce a very basic email, that tick the box of the requirement, but not pretty

V1_Email.png

So, to make it more appealing, I’m adding the “Low-Code” CSS to style the table using the compose action before sending the file

CSS_Prettify.png

Attribution: CSS is a copy from w3schools: https://www.w3schools.com/css/tryit.asp?filename=trycss_table_fancy

Now with the CSS, the table is looking more appealing

CSS_Applied.png

Another ask, can we also have this table/report as HTML. The answer is Yes. Microsoft Flow has connectors to convert HTML to PDF via 3rd party service such as Muhimbi PDF or Plumsail Documents (which requires subscription/license)

SaveToPDF.png

The quick and dirty option to save to PDF is via OneDrive actions, by creating the HTML and Convert the file to PDF.

OneDrive_Option.png

Typically you could create a folder in OneDrive to store the report temporarily and do periodic clean-up.

Then this can be added to the email as an attachment:

Add_Email_Attachment.png

Which produces the email with the PDF attachment:

Email_With_Attachment.png

And the PDF file opened with PDF reader:

Open_in_PDF.png

My Final Flow is something like this:

Final_Flow.png

 

HTH! Happy Flow-ing!

Advertisements

One thought on “Microsoft Flow: Creating Dynamics 365 Scheduled Report – Low Code Approach

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s