I am currently creating a custom timerjob that needs to execute a workflow. The timer job's schedule and the site collection on which the workflow is installed is installed should be configured through a application page.

I already have my workflow, it's custom association page to configure where the workflow should be installed, the timerjob and an application page for the timer job. However, my timer job application page is mostly empty except for a few InputFormSections that contain controls for configuring my timer job.

Now I am kinda stuck, I don't know how to continue. Basically I still need to associate the timer job with the worklow (which is installed in the chosen site). But I can't find any references on how to do this. Does anyone have any good articles or tips how to do this?


  • I don't exactly understand your need. You need to have parameter (URL SPWeb, GUID of your workflow association for exemple) on your timerJob execution?
    – Nico
    Jul 8, 2016 at 14:36
  • I need some information on how I can use a timerjob to start a site workflow. I did not create the workflow and I don't know much about them. Weird thing is, I iterate through all my sites and look up the workflow feature GUID in each site without getting any results. I can only add this workflow when I go to Site Actions -> Site Settings -> Site Administration -> Workflow settings. I assume that the workflow is a site workflow but then I don't understand why I don't get results when iterating through my site collection and searching for activated workflow feature. Jul 8, 2016 at 14:43

1 Answer 1


The timerJob is executed at different level (WebApplication, Content DB ...) You need to create (instantiate and schedule ) this timer in a feature (in event receiver of feature).

You must add your site workflow template with a feature (level site). Then, ADD workflow association to your rootSite manualy or programmatically of your site collection.

If your feature (instantiate timerJob) is WebApplication scope, you can iterate thow all site collection (webApplication.Sites), search your sitecollection (for exemple : check if the feature (level site which deploy the workflow template) is enabled on your siteCollection) get the rootsite (SPWeb) and check if your association exist in SPWeb.WorkflowAssociations.

After when you get your workflowAssociations, in your timerJob you need to get the WorkflowManager (SPSite.WorkflowManager) and use the Start methode (for exemple : mysiteColl.WorkflowManager.StartWorkflow(null, WorkflowAssociation, string.Empty, SPWorkflowRunOptions.Synchronous);)

If this answer not help you. Copy/Past your code, and I will help you

  • is a site workflow instance always inside an SPWeb.WorkflowAssociation? And does it always follow the model you described? (Get associations from SPWeb then get WorkflowManager from SPSite and execute it from there) Jul 8, 2016 at 15:30
  • When you use : Site Actions -> Site Settings -> Site Administration -> Workflow settings. And here you add your workflow instance. Actually you add a workflow Association to the Root Site (SPWeb) of your Site collection. All your workflow created or instanciate will be in the WorkflowAssociations property
    – Nico
    Jul 8, 2016 at 15:36
  • To start a workflow (level web, liste or item) programmaticaly, yes you need to get the WorkflowManager of your site collection (SPSite). And start it with the methode : StartWorkflow
    – Nico
    Jul 8, 2016 at 15:39
  • A workflowAssociation is juste a XML with all your workflow configuration (SPUser defined as approvers for exemple), a link on the workflow template ..... it's the instance of your workflow.
    – Nico
    Jul 8, 2016 at 15:47
  • Ok that clears a lot of foggy thoughts up. I was kinda confused because I thought workflows were always associated with some kind of list, even when they are created through site settings. I will try to do what you said. You really helped me out here man, thanks! On more thing though, do I need to pass the site where I got the WorkflowManager from to the StartWorkflow(Object, SPWorkflowAssociation, String, SPWorkflowRunOptions) method? Jul 8, 2016 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.