Convert a Table (entity) in Microsoft Dataverse (CDS) to PDF Using Muhimbi’s PDF Converter Online

In this blog post, we’ll be configuring a simple Power Automate solution to take all the records present in a table (previously known as an Entity) in Microsoft Dataverse (previously known as CDS) and convert them to PDF.

Microsoft states that Standard and custom tables within Dataverse provide a secure and cloud-based storage option for your data. Dataverse allows data to be integrated from multiple sources into a single store, which can then be used in Power Apps, Power Automate, Power BI, and Power Virtual Agents, along with data that’s already available from the Dynamics 365 applications.

Most organizations use tables in Dataverse to store data from different data sources to be used within PowerApps, but then there are situations where you want to share the data within these tables in a standard, portable format, such as PDF.

The Power Automate solution will be a scheduled solution that runs once a week, locates the table, takes all the records within that table, dynamically creates a HTML, and then converts this HTML to PDF, which you can then send to your stakeholders as an attachment via e-mail.

Prerequisites

Before we begin, please make sure the following prerequisites are in place:

  • As shown in the image above, Navigate to make.powerapps.com and on the page that comes up, in the left navigation window, you will see an option named Data.
  • Inside the Data option is another option named Tables (highlighted), which contains the default tables as well as the custom tables present in your Dataverse.
  • The custom table named SalesReport is the table where our data is stored and we’ll be converting the records inside the SalesReport table to PDF.

Here is what our table looks like in the PowerApps Dataverse –

In the image above, you will see that there are a lot of columns, some default and some custom. We do not need data from all of these columns to come up in our final PDF.

In order to exclude the extraneous data when we dynamically create the HTML for the table SalesReport, we will chop and choose only the data from the relevant columns. This way, our PDF will only include the data we want to showcase.

Here is a view of the overall structure of our Power Automate solution-

Step 1 – Trigger

  • The trigger that we will choose here is Recurrence.
  • As shown in the image below, configure the Interval option with a value “7” and frequency as “Day“.
  • This configuration will run the Power Automate solution once every 7 days.
  • Configure the Start time as 2020-10-15T04:30:00:000Z.
  • 2020-10-15 is the date in yyyy-MM-dd format.
  • T is a separator between Date and Time.
  • 04:30:00:000 is time in the HH:mm:ss.SSS format.
  • The trailing Z conveys the time zone data.

Step 2 – List Records

  • In the Entity name, as shown in the image below, click on the drop down and choose the appropriate table ‘SalesReports‘.

Step 3 – Create HTML table

  • As shown in the image below, for the *FROM field, navigate to Add dynamic content line and choose value from the list of options available inside the List records action
  • Next, we will configure the Header and the corresponding Value for the header.
  • Since we already talked earlier about only showing the relevant data in the PDF we will pick and choose the columns.
  • I have chosen the OrderDate, Unitcost, Units and TotalSalesRevenue here and for the corresponding Headers, navigate to Add dynamic content line and choose OrderDate, Unit Cost, Units and Total as options available under the List records action.

Step 4 – Convert HTML to PDF

  • For the Source URL or HTML action as shown in the image below, enter the HTML as below
<html>
<h2> Weekly Sales Report </h2>
@{body('Create_HTML_table')}       ---> Output of Create HTML table action
</html>
  • For the Page orientation choose Landscape.
  • The Authentication type here will be Anonymous.

Step 5 – Send an Email

  • For the Attachments Name -1 option as shown in the image below, navigate to Add dynamic content line and choose Base file name option available inside the Convert HTML to PDF action.
  • Do not forget to add an extension .pdf after the name or else the email will be generated with an attachment without extension.
  • For the Attachments Content as shown in the image below, navigate to Add dynamic content line and choose Processed file content option available inside the Convert HTML to PDF action.

That’s it, now we run the Flow and check whether we get the output as intended.

OUTPUTS

Keep checking this blog for exciting new articles on using The Muhimbi PDF Converter with SharePoint Online, Microsoft Flow, Power Apps and document conversion and manipulation.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s