A better SharePoint connector – part 2

In my search for a better CRM – SharePoint connector, I described in the previous article that an idea popped up while running. In a nutshell the connector is going to store documents inside SharePoint without letting the user notice that the documents are not stored within CRM. I made the assumption that documents are stored as attachments in annotations (notes), the funtionality is going to be developed as a plugin.

The reason why I want a better SharePoint connector is that I’m convinced that documents should be stored using meta data to classify the document. The plugin is not going to use folders as folders cripple the flexibility and power of SharePoint.

In the article “Integrating CRM Online and SharePoint Online: I need a hammer!” I described the problems I ran into while connecting to SharePoint online. Therefor the connector is going to be based on REST technology.

The plugin is going to provide insert, delete and read functionality.

Adding a new attachment

When adding a new attachment, the plugin will be overriding the PostCreate event. The PostCreate event is going to perform the following steps:

  • Check if the annotation is a document (IsDocument has to be true)
  • Get the Base64 string encoded data of the DocumentBody field
  • Get the Filename
  • Verify if the document exists within SharePoint, if it does then add a timestamp to the file name
  • Create the file in SharePoint using the (modified) file name
  • Get the ID of the new file created in SharePoint
  • store both the document url and the ID inside the DocumentBody field
  • Get all meta data we want to use for document classification
  • Update the document record in SharePoint using the meta data

The reason I’m going to store both the document url and the ID of the document, is that for reading it is easier to use the URL and for deleting it is easier to use the ID value.

Deleting an attachment

When deleting an annotation in CRM, the document stored in SharePoint has to be deleted as well. This is going to be achieved by overriding the PostDelete event in the plugin.

  • Use the ID value to delete the document in SharePoint

Retrieving an attachment

When retrieving an annotation in CRM, the plugin is going tooverride the PostRetrieve and PostRetrieve multiple events.

  • Modify the filename
  • Retrieve the binary data from SharePoint and stream it like an ordinary CRM document

What’s next?

In order to build the SharePoint connector, I have to setup a local development environment containing CRM, SharePoint and Visual Studio. The connector is going to be build in a fashion that it can be deployed on both on-premise and online environments.

Leave a Reply

Your email address will not be published. Required fields are marked *