Convert Word to PDF file using Microsoft Flow in Dynamics 365

In this blog, we will try to convert the Word file that is attached to CRM record into PDF file and then store that converted file on OneDrive. After that, we will attach that file back to CRM record and delete the Word file from CRM.

Microsoft Flow

Microsoft Flow is a cloud-based service that makes it facile for line-of-business users to build workflows that automate time-consuming business tasks and processes across applications and services. Utilizing Microsoft Flow, you can connect your Cognito Forms to a ton of different services; including OneDrive, Outlook 365, Dropbox, Gmail, and more.

Key terms for Flow

  • Flow – a flow is the connection between two packages (ex: Cognito forms and Google drive).
  • Trigger – a Trigger is the event that starts off and invokes a flow. As an instance, if you desire to create a new subscriber in MailChimp every time a brand-new form is submitted, the brand-new form entry becomes the Trigger. Cognito Forms triggers consist of:
    • Update Entry – Triggers when someone updates a record (i.e. an access this is submitted while the status isn't incomplete).
    • New Entry – Triggers while someone creates a new entry.
  • Action – An Action is the event that performs a flow. Cognito Forms triggers include:
    • Create Entry – Creates a new form entry.
  • Condition – Specify that a flow performs one or more duties simplest if a specific circumstance is true.

Steps to Creating a Microsoft flow to convert this word file from notes into pdf

Step 1: Now Login to Microsoft flow and you will see below screen after login.

Login to Microsoft flow

Step 2: Now Go to My Flows > click on New > click on Create from blank as shown below

My Flows

Step 3: After that we will selecting trigger that we want to use in this scenario we will be using “When a record is created” as highlighted in below image.

When a record is created

Step 4: Now we will select the “Organization Name” as well as the “Entity Name” that we want to utilize. In our scenario, we are using Notes.

Organization Name

Step 5: Now you will see below screen click on “New step” to add a condition.

New step

Step 6: Now we will select the “Condition” FileName which is equal to the File that we want to convert as shown in the below image.

Condition FileName

Step 7: Now we will create an action in which we will first connect with OneDrive for Business as shown in below image.

OneDrive for Business

Step 8: Now we will select Action from OneDrive for Business that we want to utilize in our scenario. It will be “Create file”. You can see this in the below image.

Create file

Step 9: After that we will fill the required fields that is either selected or we will utilize the function “base64ToBinary” (base64ToBinary(triggerBody()?['documentbody'])) to get the body of the reference file and create a clone on OneDrive as shown in the above image.

Detail related to base64ToBinary
Return binary version for a base64-encoded string.
Parameter: String Type that is base64-encoded string to convert and its Required

Return value: String Type that is binary version for the base64-encoded string

base64ToBinary

Step 10: Now we will add another Action to convert the file and provided the desire value “File” give the Id and Target type is PDF as seen in below screen.

Target type PDF

Step 11: Now we will add another Action to Create a new record. Within that, we will create a Notes entity record and provide the Document content from the Previous action as highlighted in below screen.

Document content

Step 12: Now we will add another Action to Delete file. It will delete the file from OneDrive but in order to do that, we will need to provide the File with Id from the previous step in which we have created the file as highlighted in below screen.

Action to Delete file

Step 13: Now we will add another Action to Delete a record. In that, we will delete a Notes entity record that contains the docx file that we recently created. To do this, we also need to provide Item identifier with the records that we need to delete as highlighted in below screen.

Item identifier

Run the Flow from CRM and see Output

Now we will add the docx file to an account record.

Run the Flow from CRM

Once the Flow gets triggered, it will convert the docx file to PDF file as shown in below image.

Flow gets triggered

Now, we login to the flow and check the Run History of it.

flow check the Run History

Hope this will be helpful.

Thanks!!!

Conclusion

So, here we have accomplished the successful conversion of the docx file to the pdf with the help of Microsoft Flow as the connector between Dynamics 365 and we have also learnt how to attach it with the record.

2 thoughts on “Convert Word to PDF file using Microsoft Flow in Dynamics 365”

  1. Hi there! This Flow template provides a no code solution to a development gap I’ve been facing! I have followed your instructions to build a Flow in my environment. When I test, the Flow succeeds through Step 9 (it creates the file in OneDrive), and then fails (does not convert the file to PDF). Error includes “status = 406, message = bad request, source = api.connectcorp.svc.ms.” Any ideas?

  2. Hi @Sarah Compter,

    Thank you for getting in touch with us. Unfortunately, it’s Microsoft connector issue as it is mentioned in the error, so you need to create a ticket with Microsoft Helpdesk. Please let us know if you need any assistance.

    Regards,
    BOLDEnthusiasts

Leave a Reply

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