Kilhoffer
Kilhoffer

Reputation: 32906

How do I obtain the id of a workflow created in Sharepoint Designer?

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?

Upvotes: 1

Views: 5313

Answers (1)

Bryan Friedman
Bryan Friedman

Reputation: 544

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.

Upvotes: 2

Related Questions