05 March 2012

Showing "Failed" for a SharePoint 2010 Timer Job Status

I have been working with a bunch of custom timer jobs for last month.  Basically, I’m processing a bunch of SharePoint items from the timer job and since I don’t want the job failing because of an error on one item, so I’m handing errors on an item-by-item basis and just continuing on with the next item.  The net result of this, I soon found, is that my timer job actually says it ran successfully even if every single item fails.  So I figured I would just set the “Failed” status on the timer job is anything went wrong so an administrator could see that not all was well.

However, I quickly found that there is no way to set a timer job status.  If you want the status to show up as “Failed” then the only way to do it is to throw an exception.  In my case, I just used a flag to store whether or not an error had occurred, and if so the the timer job throws a an exception just before existing to let the status display correctly.

Keep up to date with Simple-Talk

For more articles like this delivered fortnightly, sign up to the Simple-Talk newsletter

This post has been viewed 3494 times – thanks for reading.

  • Rate
    [Total: 0    Average: 0/5]
  • Share

Damon Armstrong

Damon Armstrong is a Senior Engineering Team Lead with GimmalSoft in Dallas, Texas, and author of Pro ASP.NET 2.0 Website Programming. He specializes in Microsoft technologies with a focus on SharePoint and ASP.NET. When not staying up all night coding, he can be found playing disc golf, softball, working on something for Carrollton Young Life, or recovering from staying up all night coding.

View all articles by Damon Armstrong

Related articles

Also in Blogs

Ten Years Later

It’s hard to believe, but Simple Talk has now been going for over ten years. Thanks to brilliant pieces from our writers, hard work from the team here, and countless valuable contributions from you, our readers, we’re currently receiving one million page views a month, and sitting on a hefty 2,500 articles from over 370 … Read more

Join Simple Talk

Join over 200,000 Microsoft professionals, and get full, free access to technical articles, our twice-monthly Simple Talk newsletter, and free SQL tools.

Sign up