Create custom invoices from Microsoft Dynamics 365 CRM in Power Automate

This article shows how to generate customized invoices for a selected order in Dynamics 365 CRM using Power Automate (Microsoft Flow). Sometimes Dynamics 365 functionality for creating invoices is not enough if you need to include some additional information or even a company logo.

In this example, we will use the Plumsail Documents connector for Power Automate to create customized documents populated with Dynamics 365 CRM data.

Start document generation process action

Our Flow to do the job is simple:

Generate custom invoices from D365 orders Flow

Now let’s look into each step.

Configure process

Before you proceed to create the Flow, you need to create and configure the process which will generate PDF invoices from a DOCX template.

To start, register or login to your Plumsail account.

Create new process

Click on the Add Process button.

add process button

Give a name to the process and select DOCX for a template type.

Name process and select template type

Configure template

You clicked the Next button, and found yourself in the first step of the process - Configure template.

It includes two substeps:

  • Editor;

  • Settings.

In Editor, you can compose the template from scratch or upload a pre-made one. It’s also possible to modify the uploaded template online.

Feel free to download an invoice template used in this example.

Then upload it to the process.

upload template file

Templating syntax

To compose a template satisfying your demands and your circumstances, please, get acquainted with how Plumsail Documents Word DOCX templates work. There’s nothing complex here - everything between such curly {{ }} brackets is variables where the templating engine will apply your specified data. The syntax is easy yet powerful - it supports lists, tables, charts, and many more.

Test template

You can check how the resulting file looks if you click on Test template.

You’ll see a form with fields that correspond tokens from your DOCX template. You can adjust the default form. Find more information in the documentation.

Test template dynamics

To test the Word DOCX template, enter some data into the fields.


This is testing. We will pass data from Dynamics 365 CRM to the process. See the Start process section.

Click Save & Next to proceed to Settings. Here you’ll see the following parameters:

Mode. It’s Testing by default, which means runs of this process are free of charge for you, but the resulting documents will have a Plumsail watermark. To remove it, switch mode to Active.

Output filename. To personalize it, use tokens from the template. They will work the same way as for the template. For example, we have {{customer}} token. The real customer name will replace this token, and we’ll get the file “Invoice for David Navarro”. It will change dynamically according to specified data.

Output type. The default is the same as the template’s format. It’s possible to select PDF.

Test template. Once you’ve customized all the settings, you can test the template to see the result as we did it previously.

Configure template for Dynamics CRM step

When everything is done here, click on Save & Next to set up deliveries.


It’s possible to add as many deliveries as you need. For instance, you could save the resulting invoice to your SharePoint library or OneDrive folder, then send as an e-mail attachment to the customer. Check out the full list of available deliveries.

We’ll add an email delivery for demonstrating purpose. It will deliver the invoice completed with Dynamics 365 data to the customer.

We put token {{email}} as a recipient’s email address. So, it will adjust dynamically every time according to the specified data. We’ll pull it from Dynamics 365 CRM.

We filled in the subject and email body.

email delivery

Start process

We’ll start the process from Power Automate (Microsoft Flow).

Create Flow

We’ve decided to trigger the Flow for a selected record (order) in Dynamics 365 CRM.

For that, we use Common data service - When a record is selected.

When a record is selected

The environment parameter is Default, the entity name is Orders:

When a record is selected trigger

Besides, we added an input date to be able to use the trigger date in the template.

The trigger is done, the next step is - Get a record.

Get a record

This action is from Common data service too. We need to assign it to pull the details on the order products and their properties as the trigger alone won’t provide us with this data.

Get a record step
  • Entity name - Orders;

  • Item ID - Select Order from the dynamic content of the trigger output.

  • It’s important to expand advanced settings and customize Odata query. Insert order_details into the Expand Query field. Otherwise, the Get a record action will return the same data as the trigger - without information about products related to the order.

Now save the Flow and launch a test run. After it ran successfully, copy JSON data from outputs of Get a record.

Get a record outputs

You’ll need it in the next action - Parse JSON.

Parse JSON

We assign this action to pull out data on products separately from other data we don’t need.

Parse JSON action
  • Content - Select Body from the dynamic content of Get a record outputs.

  • Schema - Click on Generate from sample and paste JSON you’ve copied earlier into the dialog.

We’re moving to the last step - Start document generation process.

Start document generation process

This is the action from the Plumsail Documents connector for Power Automate - it will start the process we’ve configured.

If it’s your first time using Plumsail Documents actions in Flow, be ready to create a new connection and provide Power Automate with Connection name and Access key:

create flow connection

You can type any name for the connection. For example, Plumsail Documents.

Then create an API key in your Plumsail Account page, copy and paste it to Access Key field.

The Start Document generation process has two parameters:

  • Process name - Just select from the dropdown.

  • Template data - specify it with dynamic content from the trigger, which pulls data from Dynamics CRM. To specify products array, insert order_details - you can find it in dynamic content of the Parse JSON output. No need to wrap it with quotation marks.

Start document generation process action

That’s it. To launch the Flow, select an order you need to generate an invoice for -> in the top navigation menu go to Flows -> and choose the Flow:

Start document generation process action

Once the Flow ran successfully, the customer receives a personalized email with the invoice attached:

invoice created from dynamics 365 CRM

Use ready invoices in Flow

It’s possible to continue working with the generated invoices from Dynamics 365 further in Flow. For example, you can send them for approval. Just add the result file returned by Start document generation process action as an attachment:

Send Dynamics 365 invoice for approval


Now you know how to generate customized invoices with logos from Microsoft Dynamics 365 using Plumsail Documents in Power Automate Flow. Utilize this approach to create any custom documents from any entities in Dynamics 365.