Visual studio 2012 Workflows Document Set
In one of my blog, I talked about options to create document set through visual studio workflow for SharePoint 2013. I want to extend that blog and show you how to actually use HTTPSend activity in Visual studio 2012 and also create document set by passing the context of the user (SPWorkflowActivationProperties.Originator).
For this first create a WCF service in Visual studio 2012 to deploy in SharePoint 2013 farm (under layouts folder); Make sure that you deploy it as a farm solution since sandboxed solutions do not support WCF services and moreover Sandboxed solutions are deprecated in SP2013. Include your code to create document set using SP OM. You can download the entire solution attached at the bottom of this blog.
Next create a workflow in Visual studio 2012 and add a LookupWorkflowContextProperty activity. It’s a new activity that gives the details about the current workflow instance running.
With this activity we can get the initiator of the workflow and then pass the information to custom WCF service. We will have to use this information to create SPUserToken and then pass the token to create an instance of SPSite.
In the workflow, add HTTPSend activity and point the Uri to our custom WCF service along with input parameters; in this case it’s Site URL and the User login details.
Finally deploy both custom WCF service and Workflow solution in your SharePoint farm. When the workflow is run, it will create a document set (by WF Originator).
Download complete solution WF_DocSet Solution