Question

I've written an event receiver that programmatically kicks off a workflow, but it needs the id (guid) of the workflow to start. How do I go about obtaining the id of the workflow(s) I just created in Sharepoint Designer?

Was it helpful?

Solution

Since you created the workflow in SPD, you should know the list that the workflow is associated with and also the name of the workflow. Armed with that information, this should work:

Guid workflowGuid = list.WorkflowAssociations.GetAssociationByName(WORKFLOW_NAME, CULTURE_INFO).Id;

If you don't know or don't want to deal with the CultureInfo part, I suppose you could also loop through the SPWorkflowAssociationCollection and just find the right workflow, but this code seems cleaner to me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top