Tuesday, October 22, 2013

Build Collections for Composite Task

For a Composite Task you need to define executors and set AssignedTo field. This field has a specific type InArgument<Collection<string>>. So you need to build a collection of strings and specify it to Composite Task activity. Let's take a look.

Tuesday, August 6, 2013

Start SharePoint 2013 Workflow Programmatically

If you want to start workflow from server-side code, you need to use Microsoft.SharePoint.WorkflowServicesBase DLL.
If you don't see it in reference search, you can find it in GAC C:\Windows\Assembly with standard windows explorer search (of course if you have installed Workflow Manager).
And then to start a workflow:

 protected void StartWorkflow(SPWeb web, Guid workflowID, int itemID)  
   var wfsrvmng = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);  
   var wfsubsrv = wfsrvmng.GetWorkflowSubscriptionService();  
   var wfsub = wfsubsrv.GetSubscription(workflowID);  
   var wfi = wfsrvmng.GetWorkflowInstanceService();  
   wfi.StartWorkflowOnListItem(wfsub, itemID, new Dictionary<string, object>());  

where workflowID you can find in the workflow Elements.xml

 <Property Name="WSGUID" Value="..." />  

Wednesday, July 31, 2013

Update Lookup Field in the List Item in Visual Studio Workflow

When you want to update lookup column in your list item, you need to use UpdateListItem activity especially.
For example, your column has static name "MyColumn". Then you need to set path "MyColumnId" to id of the lookup value item (your Int32 variable):

Sunday, July 28, 2013

Lookup Activities in Visual Studio 2012

When you develop a workflow in VS 2012 you probably want to work with other lists of your SPWeb, not only the current list either the task list. But you may get this error:

 System.FormatException: Expected hex 0x in "{0}".   

Problem is that substitution "$ListId:Lists/MyList" doesn't work in flow scope.