Power Automate is a service that helps you create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more. Today we will see how we can convert a note in CRM from word to pdf with Common Data Service Connector.
Lets login to Power Automate and create a new solution:
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/1-3-1024x459.png)
Once the solution is created, we can start creating the flow by clicking on New Flow:
Select ‘When a record is created, updated or deleted’:
We will now add the trigger for creation of notes for account:
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/4-1.png)
Next, we will check whether entity is ‘Account’ and the document is a word document so we can convert it to pdf.
![](https://optimallogics.com/wp-content/uploads/2020/12/Generating-a-PDF-for-CRM-Note-from-Power-Automate-2.png)
Below are expressions to check word document.
- contains(triggerOutputs()?[‘body/filename’],’doc’)
- contains(triggerOutputs()?[‘body/filename’],’docx’)
Since we will convert the document using ‘OneDrive For Business’ connector, so the first action will be to create a file in ‘OneDrive for Business’.
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/6-1.png)
We can use the same file name from the notes file but for file contents we need to convert from base64 string to binary by using this formula base64ToBinary(triggerOutputs()?[‘body/documentbody’]).
We will now convert the file to PDF using ‘OneDrive for business’ connector:
![](https://optimallogics.com/wp-content/uploads/2020/12/Convert-to-PDF-1.png)
Since the PDF is now generated, we will add this PDF in CRM as a new note.
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/8-2.png)
We will set the following fields for creating the pdf note:
Title: Give the title of the note. It can be any string value.
Description: Give a description of the note. Can be any string value.
File Name: Give the name of the file.
Document: We have used body(‘Convert_file_to_pdf’)[‘$content’] expression.
Mime Type: We have used body(‘Convert_file_to_pdf’)[‘$content-type’] expression.
Similarly, please also note the format used for Regarding (Accounts). We will add regarding Account in this field.
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/9-2.png)
Since we have created the pdf file in our CRM with a new note in the above step. So, we don’t need the file on OneDrive. That’s why we can now delete the file created in OneDrive:
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/10-2.png)
As a last step, we can also delete the original note from CRM:
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/11-2.png)
The complete list of steps should be like this:
![Generating a PDF for CRM Note from Microsoft Flow](https://optimallogics.com/wp-content/uploads/2020/12/12-3.png)
Now, lets create a note in CRM by uploading a word document:
![Generating a PDF for CRM Note from Power Automate](https://optimallogics.com/wp-content/uploads/2020/12/13-2.png)
However, after a few seconds when our flow will run the document will be converted into pdf
![Generating a PDF for CRM Note from Power Automate](https://optimallogics.com/wp-content/uploads/2020/12/14-2.png)
we have now successfully converted the word file to pdf using Power Automate.
For questions or insights, leave a comment below or reach out to us at info@optimallogics.com. We are always happy to help.