A better SharePoint Connector – part 7: leftovers

In the previous 6 articles in this series, I implemented a SharePoint class library. This managed class library can be used to connect to either SharePoint online  and to the on-premise version of SharePoint 2013 without using any native SharePoint libraries. In the article “A better SharePoint Connector – part 6: The SharePoint class library is born!” I enclosed a zip file containing the C# sources.

What remains to be done is to develop a plugin class that can be used within CRM. The scope for this version of the better SharePoint Connector is to use the attachment functionality offered in the Annotation (Note) entity. Once this version of the plugin is implemented, I’ll investigate other hooks from CRM to SharePoint as well (see: “Why CRM’s standard SharePoint integration hurts SharePoint!” for my motivation to write this connector in the first place. 

The plugin class has to conduct the following tasks on the following events:


PostCreate event
After the document has been uploaded to CRM, the following steps need to be taken:

  • Check if the annotation is a document (property check)
  • get the DocumentBody of the Annotation record
  • get the DocumentName of the Annotation record
  • Build a list of meta data to be sent to SharePoint
  • Send the document with meta data to SharePoint using the class library and capture the unique URL
  • store the unique SharePoint URL in a .url file insie the DocumentBody
  • Append .url to the DocumentName of the Annotation record


PostRetrieveMultiple
When fetching a list of Annotation records the DocumentName of each fetched record needs to stripped from it’s .url extension. This way the user will think the document is stored within CRM. The DocumentBody itself is not being fetched by CRM. We leave that as is.


PostRetrieve
When fetching a single Annotation record, the following steps need to be taken:

  • Check if the annotation is a document (property check)
  • Strip the .url extension of the DocumentName
  • Get the unique SharePoint URL from the documentbody
  • Download the document from SharePoint using the class library
  • Put the content of the document inside the DocumentBody field


PostDelete
When deleting the annotation, the following steps need to be taken:

  • Get the DocumentBody of the Annotation (we probably have to use a pre image to store the DocumentBody).
  • Get the unique SharePoint URL from the DocumentBody
  • Delete the document in SharePoint using the class library

In the next days I’ll write the plugin class and offer it as a download on this site.

Thank you for reading.

One thought on “A better SharePoint Connector – part 7: leftovers

  1. that guy says:

    Fantastic write-up. I have to state A better SharePoint Connector – part 7: leftovers
    is the most effective post in the topic.

Leave a Reply

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