I have a SharePoint 2013 workflow that is started programmatically. I am trying to pass a custom value to the workflow. The code to start the workflow looks like this

var payload = new Dictionary<string, object>();
payload.Add("Test", "Hello World");
var workflowServiceManager = new WorkflowServicesManager(site.RootWeb);
workflowServiceManager.GetWorkflowInstanceService().StartWorkflowOnListItem(workflow, itemId, payload);

How can I access the value in the payload parameter from within the workflow? I was so far unable to find any kind of documentation on how to do this. The value needs to be set dynamically at runtime, obviously "Hello World" is just a test value.

WorkflowServicesManager workflowServiceManager = new WorkflowServicesManager(web);
var workflowInstanceService = workflowServiceManager.GetWorkflowInstanceService();
var workflowInstances = workflowInstanceService.EnumerateInstancesForListItem(listId, itemId)    ;

Once we get the workflow Instance, we can get the instance properties as shown below. Any properties in Workflow Initiation form will also be available:

foreach (var instance in workflowInstances)
    var propertyValue= instance.Properties["Property_Name"]; //in your case it is Test

follow below link for more detail http://ranaictiu-technicalblog.blogspot.in/2013_05_01_archive.html

  • This does not suit my case. I want to access the value from WITHIN the workflow as in an activity, not programmatically. – Hatch Oct 1 '14 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.