

Var job = new StartTimerJob.StartTimerJob(List_JOB_NAME, site.WebApplication) Private static void CreateJob(SPSite site) Private static void DeleteJob(SPSite site)įoreach (SPJobDefinition job in ) Public override void FeatureActivated(SPFeatureReceiverProperties properties) Uncomment the method below to handle the event raised after a feature has been activated.Ĭonst string List_JOB_NAME = "Review Workflow" Public class Feature1EventReceiver : SPFeatureReceiver
#Sharepoint 2010 use workflow as timer code#
Below is my timerJob code and deployed as a site feature. Now when I add a timerJob, the timer Job doesn't kick-off. Your modification works great when I test it with a Console application.

SPWorkflowAssociationCollection workflowAssociations = list.WorkflowAssociations įoreach (SPWorkflowAssociation associatiedWF in workflowAssociations) SPWorkflowAssociation association = null SPContentDatabase contentDb = webApplication.ContentDatabases SPWebApplication webApplication = this.Parent as SPWebApplication Hope this may helps you public override void Execute(Guid targetInstanceId) Manager.StartWorkflow(item, association, association.AssociationData) Workflow.InternalState != SPWorkflowState.Running) Workflow.InternalState = SPWorkflowState.Running) If (workflow.AssociationId = association.Id & var association = list.WorkflowAssociations įoreach (SPWorkflow workflow in workflows) This line below doesn't work when tested in Console App. This line below works fine when tested with console app.Īssoc = ("Review Workflow",CultureInfo.CurrentUICulture) SPSecurity.RunWithElevatedPrivileges(delegate Public override void Execute(Guid targetInstanceId)Ĭonst string siteId = " const string webId = "mysite" GetAssociationByName in the timerJob definition as below, the workflow doesn't start. If I use the Guid ID and test this code from a console app, it doesn't work but when I use GetAssociationByName in the console application it start the workflow fine. I am starting a workflow with a timer Job- see code below.
