Upload Crm Note Attachment to Sharepoint Online

We had a request to implement some functionality to move attachments added to Notes into SharePoint. On the customer'south system, a lot of Notes (with attachments) had been added over the years and it was really hitting the storage costs difficult. The per gigabytes per month price of storing information in CRM compared to SharePoint is significantly higher which, depending on when you read this, could be anything effectually 10 to 20 times more expensive. Anyway, subsequently a chip of enquiry, information technology turns out there were quite a few blogs nearly this… then hither's another 1!

Getting started – how to move files from Notes in Microsoft Dynamics 365 CRM into SharePoint

So this should be everything we demand; we have the file (attached to the Note), along with its filename, and we know where we want to put it. Sounds elementary.

Showtime of all, we need to pick a tool to practise this and, without question, it will be Microsoft Power Automate from the Microsoft Power Platform. Let's get started.

When we're in Power Automate, we demand a trigger, and it's got to be the creation of a Notation.

The adjacent matter that I would suggest information technology needs is a break clause to stop this running if there'southward non really a file attached. We have a few options hither (if the filename is blank, if the Is Document field is No, if the file size doesn't contain information), but I picked the file size selection for this example.

So there'southward null in the 'Yeah' option, and the Flow volition continue, but the Flow will end and do null else on the' No' side.

On the Annotation, we've got the file itself along with the filename; nosotros need a location to move it to. This location is made up of the SharePoint site address and the folder construction. The site address is selected, and then it'south just a case of getting the folder sorted. This will be stored in the RelativeURL field in the Document Location table. To get the tape nosotros need (and at that place should simply be one), we have to look for the Regarding Object field to match the Regarding Object of the Note.

To go this information, we need to utilize the List Rows feature and filter the results by the Regarding Object.

Every bit with all List operations, we and then employ the 'Apply to each' to become through these records, although there should only be 1 returned.

So the folder is made upward of the table's name and the data in the RelativeURL field. The tabular array'southward name can come from the Object Type Lawmaking attached to the Annotation. This brought up another issue – what if the Note is not linked to a tape. Well, for our employ, in that location shouldn't have been likewise many records like this, so we added another condition to perform a end check (similar to the one that checks the file size) that checks if there's data in the Regarding field.

Nosotros and so get to create the file. The site address is selected from the drop-down – very uncomplicated. Every bit yous can meet below, I used a variable to put the folder construction together. The Filename is taken directly from the Note's filename. Lastly, the file contents were the DocumentBody field of the Note, simply to motility them to SharePoint, they need to be converted using the 'base64ToBinary' expression.

Finally, nosotros demand to remove the file from the Note. This is washed with a simple Update stride to ready Is Document to No and put a null in the DocumentBody and Filename fields – then that's the file is gone from the Annotation. I also added some tests to the Description to say 'File moved to SharePoint' to make it clear that this has happened.

This was tested, and, hurrah, it works… upward to a betoken. The first couple of times it ran was confronting custom entities, and I saw the contents of the Note update, and the file appears in the SharePoint location.

Withal, when I tested it against a Example and an Opportunity, I saw the Menstruum run and the file disappear from the Note, but cypher appeared in the SharePoint file location. After a chip of investigation, I found that the SharePoint location for these tables isn't following the same rules as the custom entities, every bit the SharePoint structure in Dynamics is set to be based on entity. This means it's creating more folders for it to be put in, So for the custom entities, the structure is:

<Site Address>/<Custom Table name>/<Unique Binder>/<File Name>

However, if we pick the Opportunity tabular array, information technology'southward using the following construction:

<Site Address>/<Business relationship>/<Unique Account Folder>/<Opportunity>/<Unique Opportunity Folder>/<File Name>

To solve this, we simply did some other List Rows, which gets the two folders for the linked Account and used these forth with the other List Rows to get the full folder structure. This did work, merely we had to add together more conditions based on the table linked to the Annotation, then it started to go a bit complicated. The other option was not to select the 'Based on entity' option when setting upwards SharePoint.

So that was about it for getting this sorted, merely in that location was one more gotcha.

Dynamics does not create the SharePoint binder by default; it simply does it when a user clicks in the Related department and and then on the Documents link. To get around this, at that place'due south a couple of options: either become a process to create this folder and corresponding Document Location record (which is quite involved) or add a subgrid to the form which accesses the SharePoint documents (which is considerably easier).

In conclusion, this functionality, which seemed fairly straightforward at first, got ever more than complicated as nosotros went through, simply we have managed to solve this. However, when you consider that storage in Dynamics 365, on a per GB per month basis, is over 10x more expensive for Dynamics than it is for SharePoint, information technology is worth doing in the long run to save these storage costs.
For more than information or guidance around Microsoft Ability Automate or any other tools in the Power Platform, please get in bear on with your Business relationship Manager. Or, why not sign up to our free and virtual workshop, which will explore Power Automate in more detail: https://www.tecman.co.uk/events-and-training/workshops

bryangoiderink.blogspot.com

Source: https://www.tecman.co.uk/power-platform/item/369-move-note-files-to-sharepoint

0 Response to "Upload Crm Note Attachment to Sharepoint Online"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel