Thursday, October 13, 2016

Creating a new Documents view in CRM to display SharePoint documents

Integration between SharePoint and Dynamics CRM allows you to link documents to Dynamics CRM entities but the documents will be stored in SharePoint instead of the CRM database (See Using SharePoint Online to store Dynamics CRM Online Documents for more information). This allows you to take advantages of the strenghts of both platforms but one of the things missing is how you can surface metadata/document properties from linked documents in Dynamics CRM.

In  Showing SharePoint document properties in Dynamics CRM views I  already explained how you can adapt the standard Associated Documents view to show extra document properties from documents stored in SharePoint document libraries. In this post, I will explain how you can create new views for the SharePointDocument entity.

If you just create a new view and try to make it work out of the box you will see that this not works. You will need to export your CRM solution. You will notice that the exported zip file contains three XML files.

  • solution.xml : Contains the details of the solution package including publisher information and a listing of any missing or key dependencies
  • [Content_Types].xml : standard Microsoft export file that identifies the content of the solution. The [Content_Types].xml file type is part of the Open Packaging Conventions (OPC) standard. For more information, see OPC: A New Standard For Packaging Your Data on the MSDN Web site.
  • customizations.xml: this file contains all of the content and mark-up that you will need to change.

Now if you look at the SavedQuery XML from the custom view which I configured in the view editor (left side of the image below), you will notice that it is quite different from the Associated Documents view that I customized previously (See Showing SharePoint document properties in Dynamics CRM views )

For a description of the different XML nodes and attributes used you can take a look at the Saved Query XML Reference but the most notable differences in the Associated Documents grid are the following – and these are also the changes that you need to make in the XML for your custom view.
  • SharePointDocument.RetrieveDocument – the official documentation only states that a string value is expected but not really what value is needed. For integration with SharePoint you need to specify SharePointDocument.RetrieveDocument
  • – defines a set of columns to return in a saved query, it seems that it is necessary to also take over a number of SharePoint specific columns.  (Reference: Saved query XML reference columnsetxml   )
  • (Reference: Saved query XML reference layoutxml )
  • 0  -  0 is for a normal main application view,  2 is for an associated view (Reference: Saved query XML reference querytype )
  • – here you need to specify the additional SharePoint document metadata columns that you want to show in the grid
After you have made the changes to view as outlined above you will see that your custom view will also work correctly. I have added the full savedquery also in Sample SavedQuery download link. In a next post I will outline how you make it possible to modify SharePoint document properties from within the CRM interface.

Related posts:

No comments: