Hi
I'm trying to workout how to call aSharePoint 2013 workflow 4.0 in code from within my eventereciever.
Previously in SharePoint 2010 was able to get workflow association and start workflow from the ie:
SPWorkflowAssociation associationTemplate = itemToUpdate.ContentType.WorkflowAssociations.GetAssociationByName("WorkflowForTesting - ItemUpdated", web.Locale);
site.WorkflowManager.StartWorkflow(itemToUpdate, associationTemplate, associationTemplate.AssociationData, true);
I found some minimal doco at msdn ttp://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflowservices.workflowsubscription.aspx "Overview of workflows in SharePoint
2013"
But has no examples and it suggests to use WorkflowSubscriptions which requires the reference to Microsoft.SharePoint.WorkflowServiceswhich is not available when I go to add the reference within Visual Studio 2012 in my event receiver project.
Any ideas/suggestions?
UPDATE:
I have worked out how to get the subscription... to get access need to add the SharePoint.WorkflowServicesBase.dll from the GAC to then add the Microsoft.SharePoint.WorkflowServicesreference.
Now trying to work out how to call the workflow for the required item...
var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);var subscription = wsm.GetWorkflowSubscriptionService().GetSubscription(new Guid("{2DC2893B-DEC0-433A-BB34-8DC0CD9CC8FC}"));
var payload = new Dictionary<string, object>();
payload.Add("ID", itemToUpdate.ID);
payload.Add("ItemId", itemToUpdate.ID);
payload.Add("WorkflowStart", "StartWorkflow"); //for manual start
wsm.GetWorkflowMessagingService().PublishEvent(subscription.EventSourceId, subscription.Name, payload);
Again no clear documentation on how to use the publishevent method provided... any help would be good.