1
votes

I've hit an issue with creating a timer job on demand from within an event handler. It works fine on my dev machine where the user is also the farm administrator. On the staging server (and production too), this user will be different. Apparently it needs to be a farm admin who creates/updates timer jobs as they have access to the configuration db.

I used a timer job to cope with the notion that many items could be updated at once using the datasheet and if that happened, I wanted an update rollup to take place at a defined period after the edits.

I'm now thinking I may have to set up a recurring timer job instead of a "once" job and within the timer job, check for certain conditions being true before doing any work.

Any suggestions on how I could achieve my desired result of having a rollup function run after any updates, but not after every one?

2

2 Answers

1
votes

The previous answer is not correct, or at least not correct for SharePoint 2010. You cannot create job definitions in 2010 in this way even with elevated privileges, as they must be created from central administration. I had a similar problem and this was my finding this is a blog I wrote about that

I would suggest that you make an event receiver that with a delay of say 10 minutes (timer or thread sleep) and register itself in say web property bag, so that another instance would not run. This could solve the problem.