Advancing from my original intent to run things via a Workflow as per this original question, I've started to work on a complex, configurable Timer Job that reads from each listitem to determine the appropriate flags for each action it takes.
However, most of the tutorials and demonstrations I find for this work on the Web Application level (as timer jobs are installed there). I need this to be run on a site collection level, and only on specific site collections (the selection of which will change over time).
How can I adapt a timer job to be scoped to specific site collections? In the feature that is responsible for adding the Timer Job, I've tried adding various properties of the current SPSite as a property of the custom SPJobDefinition, but they either don't stick, or don't work. I've tried storing the ServerRelativeUrl
property (which the SPSiteCollection[] indexer says you can use to specify), I've tried using First(s => s.ServerRelativeUrl.Equals(storedvalue))
on the SPSiteCollection, and variations on the container to store these items. Nothing has worked.
- How can I properly specify inside the Timer Job what site collections should be looked at? How can I properly reference and modify these values as site collections phase in and out of production?
- If it is not possible to store this in the Timer Job itself, how best should I iterate the site collections and determine which ones need to actually run the process? The number of sites may grow very fast so it would ideally need to account for an increasing number of site collections to run by.