As outlined in a previous blog post, Dynamics CRM provides out of the box integration with SharePoint – meaning that you can upload your documents into SharePoint directly from within the CRM user interface and link them to specific CRM records (See
Using SharePoint Online to store Dynamics CRM Online documents for more details). This same integration scenario is also available for Dynamics CRM on-premise and SharePoint Server on-premise deployment. From Dynamics CRM 2016 onwards it is also possible to use hybrid integration scenarios where as outlined in
Setup SharePoint Integration with Dynamics CRM
The preferred method for integration is using Server-to-server integration (See Integrate Microsoft Dynamics CRM CRM with SharePoint) but there are some noticeable differences between the Dynamics CRM List component and server-based SharePoint integration as outlined in
Important considerations for server-based SharePoint integration as well as
SharePoint Integration Reloaded Part 1 from Scott Durow. From Dynamics CRM
One of the great features which is enabled using server-based SharePoint integration is the fact that you are also able to show fields (or site columns) which are added in SharePoint within the Documents view in Dynamics CRM. Site columns or library columns (also referred to as fields or attributes) are used to organize documents so that people can find back the documents they need more easily. Document libraries in SharePoint are like real libraries where you can borrow books, a library has a system in place to search for the books by publication year, author, language, genre, age category, etc… In a SharePoint document library you would use site columns or library columns which would contain this information. This is also called metadata – “data (information) that provides information about other data”. So if you enable document management on the Account entity in CRM using server-based-integration it would look like the screenshot below.
Dynamics CRM uses a number of
entities to enable the integration with SharePoint :
- SharePoint site (schema: SharePointSite): represents a location record in Microsoft Dynamics CRM that points to a site collection or a site on a server that is running SharePoint Server (See SharePointSite entity messages and methods )
- SharePointDocumentLocation : represents a location record in Microsoft Dynamics CRM that points to a document folder on a server that is running SharePoint Server. You can associate the SharePoint document location records in Microsoft Dynamics CRM with the entity records for the entities for which the SharePoint Server integration or document management feature is enabled. (See SharePointDocumentLocation entity messages and methods)
- UserMapping : represents a custom claim mapping record in Microsoft Dynamics CRM to use a value other than the default value used by CRM Online for authenticating and authorizing CRM users in SharePoint (See UserMapping entity messages and methods)
Next to these three entities which are documented by Microsoft there is a 4th entity SharePointDocument which is actually quite an important entity since it is in the SharePointDocument entity that you can define additional SharePoint columns that you want to be displayed in the grid. Internally CRM will translate the FETCHXML query to a SharePoint query (CAML – Collaborative Application Markup Language ) – if you are interested to know how this is done you can use
JustDecompile and take a look at the code in the Microsoft.CRM.ObjectModel.dll which apparently has the implementation code for the SharePoint integration.
If you look at the SharePoint Document entity in CRM and check out the list of fields you’ll see there are quite a few fields (such as Title, version, etc..) that you can display. These fields will display the corresponding values from columns in a SharePoint document library if you add them to the SharePoint Document Associated View. So for example you can quite easily make the title of a document in SharePoint appear in the CRM view.
This is great for the out of the box fields but if you have modified the library in SharePoint to add additional attributes you’ll notice they are not displayed. So let’s image that you have added a custom field called DocType (of type text) in a SharePoint document library as shown below and you want to show the values of this SharePoint column in Dynamics CRM (I suppose that you already setup with document management integration already setup). You will need to perform a number of steps to accomplish this:
- Create a new solution in Dynamics CRM (you can also use the Customize the system option but this is not really the recommended way)
- Add the SharePointDocument entity and the Document Associated Grid to your CRM solution
- Navigate to the SharePoint document library that is used to store the documents linked to your CRM record and add a column of type text with name “DocType”.
- Add a field on the SharePointDocument entity with exactly the same display name “DocType” of type single line of text. Dynamics CRM will use the display name of the fields to do the mapping with the query which is send to SharePoint. All values returned from SharePoint will be of type text except for a date field in SharePoint. So you need to create fields of the corresponding type in CRM.
- Modify the “Document Associated Grid” view that you added to your CRM solution and add the newly created CRM field to this view. (This will only work with the “Document Associated Grid” view – to make this work with new views you will need some extra steps that I will outline in a next blog post)
Once you fill in the values of the SharePoint fields for the different documents you will notice that they appear in the CRM “Document Associated Grid” as well. This seems to work for the following types of SharePoint fields: text, number,date,choice, boolean,currency and person. I currently only tested the scenario in Dynamics CRM Online (8.1.0.452) in combination with SharePoint Online as well as for Dynamics CRM 2016 (Update 0.1) on premise in combination with SharePoint Server 2013 but I guess it should also work in other setups which are using server-based-integration.
References: