Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

$
0
0

Microsoft Flow allows us to connect and automate two disparate systems. And, the best part of Microsoft Flow is that both the systems need not be from Microsoft’s umbrella.

The way Microsoft Flow allows the communication between two different systems is with the help of plethora of connectors that’s available at our disposal. We can leverage these connectors based on our needs.

In our previous blog “Geo-code Dynamics 365 Records Using Microsoft Flow”, we see Microsoft Flow connect with Bing Maps Services and utilize the address information to find geo-coordinates. Now in this blog, we will be talking about such two connectors, Dynamics 365 and SharePoint and how can we leverage these to get our tedious job done with few steps of configuration.

Have you ever been in a situation where the Notes attachment are consuming the majority of your Dynamics 365 CE’s storage capacity? If yes, then this blog is specifically designed for you folks.

Say, whenever a user creates a Note with an attachment, you need a mechanism in place that will extract the attachment out of Note and upload it on SharePoint and remove the attachment from the Note leaving a URL back to the SharePoint location of the file in the Note body.

To achieve the above said requirement in the pre-Microsoft Flow era would have required a skilled developer having good knowledge of SharePoint and Dynamics 365 CE API, but, now it is possible to achieve this without writing a single line of code. See, this is where Microsoft is leaving no stone unturned to ease user’s lives.

Without further much ado, let’s dive directly to the steps that should be undertaken in order to achieve the said requirement.

Note:Wehave takenAccount entity’s Notes for this example, you can work on any entity.

Step 1:

Create a blank Flow template. Choose the Dynamics 365 Connector and Trigger as, “When a record is created”.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

Select your Organization Name, and also the entity, in our case it must be Notes.

Step 2:

Check whether the Note record that is created has a document attached to it, for this you need to add a Condition step.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

Step 3:

On its success, validate if the Note record that is created is for an Account or not.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

Step 4:

On the success of this condition, you must retrieve the Account record that is selected. The reason behind retrieving Account record is to get the Account Name, because the SharePoint folders are created in the format of AccountName_GUID. In order to achieve this, add an Action called “Get record”.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

Step 5:

Here comes the main step of transferring file onto SharePoint. This time while choosing an Action, select the SharePoint connector, on selecting the SharePoint connector, it would give you the list of Actions that are SharePoint specific. From the list of Actions, select, “Create file”.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

So, let’s see each and every parameters that has been passed.

  • Site Address– The SharePoint Site address.
  • Folder Path– The path where the file needs to be stored, for e.g., /account/A. Datum_46a68519-83a8-4bd7-a4da-1b4767bb3d6a
  • File Name– Name of the file.
  • File Content– The document body from the Note record.

The important piece here is, you need to convert base64 to binary. This is because, the Note’s attachment is stored in Base64 format and SharePoint accepts the file body in binary format.

Formula used: base64ToBinary(triggerBody()?['documentbody'])

Step 6:

The last and final step is to remove the attachment from Note and leave a URL back to the SharePoint path where the file has been stored, in Note’s body.

For this, choose action ‘Update a record’.

Move Dynamics 365 Attachments to SharePoint using Microsoft Flow

Note:

  • If for the same record, you are creating two Notes with the same file name, then the latter file will override the former file.
  • Currently, Microsoft Flow needs to be created for specific entities, due to the fact that we don’t get name of the record and we need to retrieve it in order to form our folder name.
  • If folder doesn’t exist it creates by itself.
  • Even a user having User (no administrator access) role can create Microsoft Flow, but that user won’t be able to have the SharePoint or Dynamics 365 Customer Engagement connectors under his account. They need to create connectors under different account.
  • If the attachment is added afterwards, then to handle this, we need to create a different Microsoft Flow that would trigger on update of Notes.
  • Similar approach can be used in the case of stripping of attachments from an Email received or a Sent email.

Copy System and Custom Entities in Dynamics CRM


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>