Saturday, June 19, 2010

Starting a Workflow from an Event Receiver - SharePoint 2007

Out of the Box there are only a few options to start a (custom) workflow. E.g. when an item is created or changed. This means that there are a lot of situations that a workflow is fired where it is not needed (often a workflow only needs to be started if a field has a specific value). Therefore we can write an event receiver to time better when a workflow is started. Below you find the code to start a workflow from your event receiver.


public override void ItemUpdated(SPItemEventProperties properties)




SPList parentList = properties.ListItem.ParentList;

SPWorkflowAssociation associationTemplate =

parentList.WorkflowAssociations.GetAssociationByName("Workflow Name",

new CultureInfo


SPSite siteCollection = properties.ListItem.ParentList.ParentWeb.Site;


associationTemplate, String.Empty);




No comments:

Post a Comment