1

This feature is scoped at the site collection level. When the feature activated, the timer job is created in the web application with a generic name that includes the site collection URL that it's supposed to run in. In theory, when deactivating the feature in a site collection, it stops executing there, but any other timer job feature activated on a different site collection would still run.

using Microsoft.SharePoint
using Microsoft.SharePoint.Administration

class DailyAlerts() : SPJobDefinition
{
   public DailyAlerts() : base() { }

   public DailyAlerts(string jobName, SPWebApplication webApp) : base(jobName, webApp, null, SPJobLockType.Job)
   {
      this.Title = jobName;
   }

   public override void Execute(Guid targetInstanceId)
   {
      // CHANGE THE SITE COLLECTION'S ROOT WEB SITE DESCRIPTION TO THE CURRENT TIME
   }
}

After deploying the solution, and activating it on one site collection, the job never executed any custom code. This article helped remedy that: http://www.wahidsaleemi.com/2009/08/sharepoint-timer-jobs-not-running/. After stopping the SP timer server, deleting the cached XML files, and started the service, the activated site collection timer job executed perfectly.

However activating the custom timer feature on a different site collection, caused the same initial problem of that particular site collection's timer job not executing. The first timer job (post clear cache) still works fine.

Since certain users have control can turn on/off features, you can see how this can get frustrating for people. When new site collections are made, the feature will have to be activated, but it will not run until...the cache is cleared? What am I missing here?

Thanks in advance.

  • BTW, event receivers always work correctly. – detailCode Feb 3 '15 at 15:40
  • What exactly are you trying to accomplish with your timer job? It says in your comment that you're just changing the site description to the current time. Is that all it's doing? Why not just do that with front end JavaScript? – jpollar Feb 3 '15 at 15:49
  • That's just a simple example for debugging. Once this custom timer job is working, the future code will be more complex. – detailCode Feb 3 '15 at 15:51
  • What timeline do you have for running the job in your event receiver? – jpollar Feb 3 '15 at 15:58
  • 1
    Check this out and see if it helps any... codeproject.com/Articles/70866/… – jpollar Feb 4 '15 at 3:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.