Wednesday, November 13, 2013

Clear Integration of MS Dynamics CRM2011 to SharePoint

MS has provided good integration point on MS Dynamics CRM with SharePoint document management. In order to integrate SharePoint document management with Dynamics CRM, you must install CRM List Component on SharePoint and configure Dynamics CRM for SharePoint. I am not going to cover those two tasks from this article and please follow below two articles to complete those two tasks.

1. Introduction to SharePoint Integration with Microsoft Dynamics CRM
2. MS CRM 2011 SharePoint List Component Installation

Even though integration was done fairly well, I encountered that there are few issues with that integration and they are:


1. If the primary field of the entity record has no value set, integration to SharePoint document management will be broken for particular record and CRM throws an error with message "Both absolute URL and relative URL cannot be null". It shows that error just because of value of primary field is used create relative URL(folder name in SharePoint Document Library created for the entity) for holding documents saved for particular entity record and it cannot have blank value.

2. If there are two records with same primary field value (e.g. two contacts with same name) in CRM, documents saved will be shared with both the records.

In order to fix above two issues I have come up with solution and thought it will be beneficial for others as well.


We can create common plugin, which can be registered with any entity that you need SP document management enabled and do below tasks within create method of a plugin to fix above issues. Concept behind the solution is, plugin will create SP document location in CRM and folder in SP up-front, when the CRM record is created. So then when you click on Documents link in CRM record, CRM won't try to create SP document location using value in primary fields and use the detail of a record that have been created by plugin already.

1. Get Sharepoint Parent Site LocationId in CRM using default SP site URL and target entity name.

Guid sharepointParentSiteorLocationId = GetSharepointParentSiteorLocationIdByEntity(orgServiceContext, sharePointURL, target.LogicalName);

2. Create SP folder up-front. Folder name will be GUID of a target entity record.

CreateSubFolder(sharePointInternalURL, target.LogicalName, target.Id.ToString());

3. Create SP document location in CRM. CRM will use these detail to point to a correct location of SP.

CreateSharePointDocLocation(orgServiceContext, target.LogicalName, target.Id, sharepointParentSiteorLocationId, target.Id.ToString());

If you have any question or suggestions on this please feel free to post a comment below.


1 comment: