Creating SharePoint Sites With CRM Workflow

Can I Play With Madness...

Now that I have a custom site definition that incorporates a minimal master page my next task was to automate the site creation process. I decided to build a custom workflow activity rather than a plug-in as this give me a high degree of flexibility in choosing how and when I create a site.

Following the SDK documentation for creating a custom workflow activity, the first job was to build the basic class, inherited from the workflow SequenceActivity base class.


Simply compiling this class and registering the workflow assembly with Microsoft CRM, enables this as a new activity in the CRM workflow editor.


Next, I needed to pass some parameters to the activity, including the URL of the parent site of the new site, the site template and the new site name. Again, following the SDK documentation for creating workflow dependency properties, this was pretty straightforward.


Compiling and registering the assembly exposes the input parameters to the CRM workflow editor.


In order to redirect the CRM form IFRAME to the new site, I needed to supply the new URL as a return parameter from the activity.


Again, compiling and registering the assembly exposes this output parameter to the CRM workflow editor, and in this case I am storing the site URL in a custom attribute of the CRM record.


Finally, I had to write the actual code to create the new SharePoint site. After a bit of reading, I found that the SharePoint web services provide enough functionality to achieve my objectives - specifically the Meetings.asmx and DWS.asmx web services.


Now, I'm not going to delve into the code itself, but I stripped out any error handling, logging etc to leave just the key functionality, so hopefully it is pretty self explanatory. The final piece of the solution is to create some client JScript to pass the new site URL to the CRM form IFRAME.


As you can see, the results look really good, and I can re-use this activity to create SharePoint sites for different entities without having to write any new code or register multiple plug-in events.


In order to make it easier for you to implement your own custom workflow activity, you can download the source code here. In addition, if you wish to use the functionality as-is, I've also included the compiled assembly file - all you have to do is register it with your own CRM application.

This posting is provided "AS IS" with no warranties, and confers no rights.

Laughing Boy

Comments (6)

  1. So I know that this way overdue. Way. After Convergence, I came back and went on vacation and then Beth

  2. SharePoint und Web 2.0 Knowledge and Talent in a People-Ready Business Server Side Integration of SharePoint

  3. Ramble On says:

    Yes this is possible and very easy to do in fact. All you need to do is register a custom CRM plugin,

  4. Pascal Alderweireldt says:

    Hi Simon

    I was very pleased to find this solution. I have installed this on our CRM server.

    But the workflow stops on the Create Site statement. It is not obvious why. Maybe you can help me out?

    My parameters are:

    – parent site: https://<server name>/<subsite 1>/<subsite 2> (no ending /)

    – template: <name>.stp

    – site name: MyTest (actually {topic{Opportunity}} )

    With my user account I can surf up to the parent site and create a sub workspace. So I have a feeling it is due to the template.

    What is the syntax for this parameter? And how can I find the correct names of the templates on my sharepoint (and its correct syntax to use as the template parameter)?

    Are could there be a different reason? I already tried with template parameter = blank and an ending / in the parent site.

    It would be very helpful 🙂

    Thanks in advance


  5. Simon Hutson says:

    Hi Pascal, your template name is incorrect – The template should be in the format name#number, e.g. MINIMAL#0 (the name I choose for my custom site template).

    If you want a full list of the out-of-the-box SharePoint site templates, there's a good blog posting here –…/moss-wss-sitetemplate-codes.aspx

    I hope this helps.


Skip to main content