Delen via


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.

image

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

image

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.

image

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

image

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.

image

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.

image

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.

image

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.

image

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.

image

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

CreateSite.zip

Comments

  • Anonymous
    April 27, 2008
    PingBack from http://microsoftnews.askpcdoc.com/microsoft-dynamics-crm-40/creating-sharepoint-sites-with-crm-workflow

  • Anonymous
    April 28, 2008
    So I know that this way overdue. Way. After Convergence, I came back and went on vacation and then Beth

  • Anonymous
    May 12, 2008
    SharePoint und Web 2.0 Knowledge and Talent in a People-Ready Business Server Side Integration of SharePoint

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

  • Anonymous
    August 10, 2010
    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 Pascal
  • Anonymous
    August 21, 2010
    The comment has been removed