Question

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?

Thanks

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top