User Tools

Site Tools


notes:sharepoint2010:workflows

Workflows in SharePoint 2010

Start a workflow 'myWorkflow' using elevated privileges:

// This code should be run inside an event receiver.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
    SPList parentList = properties.ListItem.ParentList;
 
    SPWorkflowAssociation associationTemplate = 
        parentList.WorkflowAssociations.GetAssociationByName("myWorkflow", new 
        System.Globalization.CultureInfo(Convert.ToInt32(parentList.ParentWeb.RegionalSettings.LocaleId)));
 
    if (associationTemplate != null)
    {
        SPSite siteCollection = properties.ListItem.ParentList.ParentWeb.Site;
        siteCollection.WorkflowManager.StartWorkflow(properties.ListItem, associationTemplate, String.Empty);
    }
});
notes/sharepoint2010/workflows.txt · Last modified: 2015/06/24 by admin