Accessing Sharepoint APIs from a CRM Plugin RRS feed

  • Question

  • Hi

    I have a plugin solution that will be regsitered on the CRM server. Sharepoint is NOT installed on this server. I need to access sharepoint APIs from my plugin. I went through the reading in the link http://blogs.msdn.com/b/sharepointdev/archive/2011/05/24/deciding-which-sharepoint-2010-api-to-use-jim-crowley.aspx

    I intially tried adding the Microsoft.Sharepoint.dll in my bin folder and running the application, but got the filenotfound unhandled exception.

    It is clear that I cannot use server side object model, since the plugin will be deployed on the web server that has crm istalled and not on the sharepoint server. But, do I use the managed client model or the web services..I need help udnerstanding that, please.

    I tried using the web service Lists.asmx, but could not find the API 'Lists'. Don't know what I am missing here.

    It is on CRM 2011 and SP 2010.


    • Edited by IamaNovice Friday, September 2, 2011 9:50 PM
    Friday, September 2, 2011 9:32 PM

All replies

  • Hi,

    Try accessing via SharePoint web service as mentioned in the following blog post: http://nikspatel.wordpress.com/2010/04/12/download-and-upload-the-sharepoint-documents-using-the-sharepoint-copy-web-service/ 

    Jehanzeb Javeed

    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, September 2, 2011 10:50 PM
  • I am not able to see a 'Copy' API under the Copy Service. Instead, this is what I see:








    Friday, September 2, 2011 11:23 PM
  • Hi Glora,

    There are on-premise only ways that you can use the SharePoint DLLs in a CRM Plugin:

    (1) Add the SharePoint DLLs to the Server\Assembly folder in the CRM Installation Directory alongside your Plugin DLL, and then register your Plugin DLL as a Disk-based Plugin.

    (2) Add the SharePoint DLLs to the GAC (Global Assembly Cache) of your CRM Server, and then register your Plugin as either Disk-based or Database-based.

    When you are looking at using the SharePoint DLL, consider using the SharePoint Client Object Model - this is new to 2010 and is structured similar to the Server Object Model but is designed to work outside of the SharePoint Server.  Have used this alongside the CRM SDK via Plugins and Scribe, and can be very useful.


    To other alternative as Jehanzeb suggests is to use the SharePoint Web Services which offer certain SharePoint functionality via Web Methods, these Web Methods do not offer all the relevant SharePoint functionality (particularly for Content Types) but in most cases can get the job done.

    One point that is worth doing for the Web Services (if a little old school) is adding the Services in Visual Studio as a Web Reference and not a Service Reference - this is handy for getting a .NET 2.0 view of the services which can be useful for people like myself who dip into development on occasion.

    Which part of SharePoint functionality are you trying to integrate?  Did a project integrating CRM 2011 and SharePoint 2010 for document management a month or two ago, so might be able to offer some advice.

    Kind Regards, Paul | http://crmconsultancy.wordpress.com
    Monday, September 5, 2011 9:05 AM
  • Hi Paul

    Thanks a lot for your assistance. I thought I tried both your options, and they did not seem to work. The error I get is this:

    "Could not load file or assembly 'Microsoft.SharePoint.Library, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified."

    Let me try them again. To answer your question, this is what I need to do in a custom workflow activity:

    Attach a document from a sharepoint 2010 folder to an email and send it to all recipients. This folder was created as a result of an account creation in CRM, automatically after the sharepoint url was configured in the CRM document management settings.

    It would be great if you can provide some examples or links pertaining to this function. Thank you!

    • Edited by IamaNovice Tuesday, September 6, 2011 3:47 PM
    Tuesday, September 6, 2011 1:41 PM
  • A simple way to achieve this result, or for testing, is to install SharePoint on the CRM Server but do not run the Configuration Wizard. The installer will place all of the required assemblies and as long as you do not run the Configuration Wizard the Admin website will not be setup and it should use little to no server resources.

    M Surmanian C3SD Inc.
    Wednesday, September 7, 2011 4:45 AM
  • Thanks, I was able to use the client object model(com) and it did not give any runtime errors. However, I am unable to use the com to access libraries. I am able to access "Shared Documents", "Links", "Tasks" etc. I do not know the title to access "Libraries". I need to download a document from "Libraries" and attach it to an email created from a workflow activity. This is my folder structure in sharepoint:

    Libraries-->account-->account1-->file 1

    Libraries-->account-->account1-->file 2


    Wednesday, September 7, 2011 12:58 PM
  • Isn't there anyone who can assist. I just need to know how I can access the folders and files directly under "Libraries", not under "Shared Documents". Am sue am missing something simple, but it's taking too much time, hence this thread. Thanks

    Thursday, September 8, 2011 3:57 PM
  • Hi Glora,

    If I understand correctly, 'Libraries' is a Document Library held within SharePoint under the Web and the code you have can access other Document Libraries such as 'Shared Documents' but fails when looking for 'Libraries'.

    Be worth posting your code up to see if anyone can spot any problems, I imagine it will look similar to the following:

                    clientContext = new ClientContext(webUrl);
                    clientContext.Credentials = new System.Net.NetworkCredential(
                    Web web = clientContext.Web;
                    ContentTypeCollection ctc = web.ContentTypes;                
                    List documentLibrary = web.Lists.GetByTitle("Libraries");

    Be worth testing this against a Document Library with a different name to see if other Document Libraries work okay - this may help determine whether the problem is with the code, or is specific to the 'Libraries' Document Library itself.

    If the problem only seems to happen with the 'Libraries' Document Library, then could be worth posting the URL that IE displays when accessing the Document Library through SharePoint normally.

    Kind Regards, Paul | http://crmconsultancy.wordpress.com
    Friday, September 9, 2011 9:00 AM