Sharepoint 2013 CRM2011 Document Upload and Document Location Helper (CSOM and OM)

Hi all,

Playing around with SharePoint CRM 2011 integration, I managed to construct a helper function that would be useful for future projects. This is when you want to upload document to SharePoint as well as creating document location in CRM 2011.

There are several ways of uploading documents to SharePoint.
1. Object Model
2. Client Object Model
3. Rest API

In this post, I will show you the first two. If your code is sitting in SP server, you can use the traditional object model. Here you go:



You might want to impersonate credentials when uploading to a different SP site. With Firefox, when I try to upload to secured SP site (https) I got prompted login box which is annoying (as opposed to single sign on with IE/Chrome).

So as a workaround we can use the Client Object Model way to upload to SharePoint in order to specify the credentials:



Here I also ensure that the folder exists before we upload document (otherwise create them!).

Lastly, the CRM 2011 document location can be created easily if they don't exist yet :)
You have 2 options (Absolute or Relative paths), I will show both functions:



There you go! Then you can just use this function in your handler class etc.

HTH,
Andreas

Comments

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

CRM Plugin - Parent and Child Pipeline

Sitecore custom publish agent from specific node and at a specific time