created a file from a Dynamics 365 CRM record attachment and when I try to load it into SharePoint it doesn’t create or read correctly?
Even if it appears to upload correctly, it may not open properly and display something like this:
Consider the following scenario. Suppose you have attached a document in SharePoint and want to save it in Notes.
- Let’s say you have uploaded this PDF document to Notes and now you want to upload it to SharePoint.
- I have a flow that sends this document to SharePoint that runs when I create a note in the Dataverse (Dynamics 365 CRM).”
- Now the “Create File” action in SharePoint looks like this:
This allows the SharePoint file creation action to add the document to the file context. Hovering the mouse over this will result in triggerOutputs()?[`body/documentbody`]. - Running this flow creates a document in SharePoint. However, when I open the file, I get an error message that the file cannot be read, even though the file appears to upload correctly.Please click on the link to find correct way to
Create a file from a Dynamics365 CRM record attachment notes and move to SharePoint documents. without corrupted file.
Use base64ToBinary conversion
Here’s a step to create a File in SharePoint in your mentioned SharePoint library –
- In order to correctly pass this through, use the base64ToBinary expression in the Create file’s File Content field.
- And in base64ToBinary, put the Document so that it looks like this – “base64ToBinary(triggerOutputs()?[‘body/documentbody’])“
- And when you re-run the test, the document will be created in the same way.
And now when you open it, it’ll open properly.