Manage Dynamics 365 Documents in SharePoint via Server-Based SharePoint Integration

28 June 2018
KingswaySoft Team

Managing files and attachments is a common requirement when working with Microsoft Dynamics 365. Since the system is not designed to store or manage documents, documents are often saved as a note. This is not the most desired appealing approach, particularly for those who require more complex document management capabilities. Additionally, saving documents as a note can become expensive for those using 365 Online due to limited storage availability.

With Dynamics 365, you can use the document management capabilities of SharePoint from within Dynamics 365. This option was introduced in Microsoft Dynamics CRM Online 2016 Update 1. With this option, you can store and manage document in the context of a Dynamics 365 record on a SharePoint Server, and leverage the SharePoint infrastructure to share, manage, and collaborate efficiently.

In this blog post, we are going to work with the server-based SharePoint integration to accomplish the document integration job.

Prerequisite

To manage 365 CE/CRM documents via SharePoint server, you would need to first set up the server-based SharePoint integration on your Dynamics 365 system. In CRM, go to Settings | Document Management and click Enable server-based SharePoint integration, then follow the steps described here to complete the Enable server-based SharePoint integration wizard.

Enable Server-Based SharePoint Integration in Dynamics 365

Once this is done, you can go to Document Management Setting to enable SharePoint document management for specific entities.

Enable CRM entities for SharePoint Integration

Once you have it configured, the SharePoint toolkit can be used to interact with the SharePoint system in order to upload documents and maintain the relationship between SharePoint and Dynamics 365.

To summarize, following are the prerequisites to work with the sample in this blog post:

SharePoint Folder Hierarchy

Once the server-based SharePoint integration is enabled, corresponded entity folders will be created in the SharePoint site based on the Document Management Settings in CRM. As shown in the screenshot below, entity name for the entity is used to create folders in SharePoint, such as Account, Invoice, or Opportunity.

CRM entities in SharePoint folders

Within each entity folder, there will be several subfolders corresponding to the records in your CRM system.

Let’s have a deeper look at the Opportunity folder, there is a subfolder called “Test Opp_FF238DA4DA4FE811A954000D3AF481F1” in our test site, which is the document location of the “Test Opp” opportunity record.

As you can see from the below screenshot, the format of the record level subfolder’s name is “[Primary Field value]_[Record’s GUID in upper case without dash characters]”. Kindly note that you would need to follow this format to create folders in SharePoint as behind the scene this folder will be automatically linked to the associated CRM record.

CRM record in SharePoint folder

Sample Data Flow

To work with different entity records, you would just need to upload files to the corresponded folder with a formatted folder name. We are going to show you the process of how to upload and associate a document with a CRM opportunity record.

SSIS data flow to create SharePoint folder for CRM records

3.1. Read local file

In or example we used the Premium File System Source component in our SSIS Productivity Pack to read file from local test environment, you can certainly use any other components to perform the same operation as long as the document is being read and imported as binary content. If you want to read file from another SharePoint site, the SharePoint Source component would be the best fit for this kind of operation.

This step will output two columns:

  • Name: name of the file
  • FileContent: binary content of the specific file

3.2 Generate folder name

Here we used a Premium Derived Column component to provide the SharePoint folder name which represents a CRM record. We followed the naming format that we’ve mentioned above to build the folder path, which are record’s primary field value and record’s GUID value concatenated by an underscore symbol.

For demo purpose, we hardcoded the value via the Premium Derived Column component, while in real integration scenario, you may need to read these values from CRM in order to build the FolderPath. There are some functions including Upper() and Replace() which can be used to generate the correct FolderPath.

  • Upper(): returns result as all upper case characters.
  • Replace(): returns result with all occurrences of search expression replaced with replace expression.

This step will generate one column:

  • FolderPath: the folder path that is going to be created in SharePoint

3.3 Create SharePoint folder

Next we used a SharePoint Destination component to create subfolder under the Opportunity folder. This will create a document location and associate it with the corresponded CRM record. Our SharePoint Destination support CreateFolder action to create folder in SharePoint, we provided the FolderPath to create the related folder.

3.4 Upload file to SharePoint

In this step, we used another SharePoint Destination component to upload files to the document location that we just created. The action we used here is Create, we mapped the following columns to upload the test file:

  • Attachment_1_BinaryContent: the image file field of the attachments for Document Libraries and Lists.
  • Attachment_1_FileName: the name field of the attachments for Document Libraries and Lists.
  • Virtual_LocalRelativePath: the folder path that attachment is going to be uploaded to.

After you have done these steps, you should find the file is created in the target folder in SharePoint and also listed under the Document Associated Grid for the corresponded opportunity record.

Please note that the SharePoint subfolder name cannot be changed, otherwise you may lose the association with CRM record even if the name of your CRM record has been updated.

Sample Package

A sample SSIS package is available for download here. The sample package was prepared in a SQL Server 2008 R2 format, and it should automatically upgrade if you are using any newer version of SSIS.

Archive

November 2024 3 October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags