locked
Create SharePoint folder from a workflow RRS feed

  • Question

  • Does anyone have an example of how to create a SharePoint folder from a CRM Workflow, i.e. we create the [Document Location] record and then need a custom workflow to create the actual SharePoint folder.

    Thanks


    Pete

    Wednesday, May 21, 2014 4:29 PM

All replies

  • We have created SharePoint folders in Plugins.  You could use this in a custom workflow activity I assume.  Here is a snippet for SharePoint folder creation:

    SharePointDocumentWorkspaceService.Dws dwsService = new SharePointDocumentWorkspaceService.Dws();
    dwsService.Url = spSiteUrl + "/_vti_bin/Dws.asmx"; // if you type this url into a browser, you will see the description of the web service DWS
    
    if (!string.IsNullOrEmpty(sharePointAccount) && !string.IsNullOrEmpty(sharePointPassword) && !string.IsNullOrEmpty(sharePointDomain))
    {
        dwsService.Credentials = new NetworkCredential(sharePointAccount, sharePointPassword, sharePointDomain);
    }
    else
    {
        dwsService.Credentials = CredentialCache.DefaultNetworkCredentials;
    }
    string response = dwsService.CreateFolder(folderName);


    • Edited by axium Thursday, May 22, 2014 2:14 PM
    Thursday, May 22, 2014 2:13 PM
  • There are a couple of deployment considerations as well:

    1. The account running the code (i.e. the account the Crm Async Service runs under), will need appropriate permission in SharePoint
    2. If you create a Service Reference to the SharePoint web service (dws.asmx), then Visual Studio would expect to read the Url from the app.config file. As the code will run in the CrmAsyncService process, you'd either have to use its .config file, or modify the code to read the Url from elsewhere

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thursday, May 22, 2014 3:51 PM
    Moderator