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.
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.