Please wait, loading...

 

Move Attachments Note or email to SharePoint using Power automate flow Dataverse Microsoft Dynamics CE | CRM

May 20, 2023

Create a file from a Dynamics365 CRM record attachment notes and move to SharePoint documents.

Click here if your file in SharePoint doesn’t load or corrupted.

 

Click here for How to Enable Dynamics 365 CRM and SharePoint Integration Step by Step

This question has been going around on the power users community forums and I thought it would be nice to blog it because it is always gets tricky trying to save files from different data sources , so for this we have a single source the outlook connector and there is two destination.

  1. Sharepoint File
  2. Dataverse Email Attachment

Lets Get Started!

So the starting point is the Flow Trigger which is “When a new email arrives (v3)”

Then the next step is to get the Attachments from the Email by using the below steps:

  1. Loop on the attachments from the triggerOutputs
  2. Use Get Attachment (v2) to get each attachment

Then to save to sharepoint that was pretty easy .. Just using the outputs of the Get Attachments (V2) has worked from the first Go!

Name and Content Bytes!

What about dataverse?

So for DataVerse we are creating a new email activity and adding the attachments to it as below but it wasn’t straight forward adding the attachment.

Step 1: Easy : Create the Email Activity

Step2: Add the Attachment and here is a couple of tricks

  1. when you select the table name attachments there is 2 tables , make sure you select first one.
  2. Attachment(Attachments) just pass null from the Expressions Pane … Weird but how this is working.
  3. Entity: Do not select one of the available Options , just use enter a custom value and type email otherwise you will get an error.

The entity with a name = ‘4200’ with namemapping = ‘Logical’ was not found in the MetadataCache. MetadataCacheDetails: ProviderType=Dynamic, StandardCache=True, IsLoadedInStagedContext = False, Timestamp=3040485, MinActiveRowVersion=3040485, MetadataInstanceId=51707140, LastUpdated=2021-08-04 11:35:57.770

And when it came to setting the body ; it wasn’t as easy as passing the content bytes directly as with sharepoint ..

Attempt 1: Pass Content Bytes directly .. Error Received

The attachment body should be a valid Base 64 string

Attempt 2: Convert Content Bytes to base 64, No error received, file was attached but corrupted

Attempt 3: Binary ???!!! .. Weird but this is what worked for me run successfully and file was not corrupted.

Hope this is useful!

 
https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more