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 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.
Step 2: Now Go to My Flows > click on New > click on Create from blank as shown below
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.
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.
Step 5: Now you will see below screen click on “New step” to add a condition.
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.
Step 7: Now we will create an action in which we will first connect with OneDrive for Business as shown in below image.
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.
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
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.
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.
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.
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.
Run the Flow from CRM and see Output
Now we will add the docx file to an account record.
Once the Flow gets triggered, it will convert the docx file to PDF file as shown in below image.
Now, we login to the flow and check the Run History of it.
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.
If you have any question or queries, do not hesitate to reach out to us!