{"id":3506,"date":"2012-03-05T21:13:12","date_gmt":"2012-03-05T21:13:12","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/showing-failed-for-a-sharepoint-2010-timer-job-status\/"},"modified":"2016-07-28T10:50:44","modified_gmt":"2016-07-28T10:50:44","slug":"showing-failed-for-a-sharepoint-2010-timer-job-status","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/showing-failed-for-a-sharepoint-2010-timer-job-status\/","title":{"rendered":"Showing &quot;Failed&quot; for a SharePoint 2010 Timer Job Status"},"content":{"rendered":"<p>I have been working with a bunch of custom timer jobs for last month.&#160; Basically, I&#8217;m processing a bunch of SharePoint items from the timer job and since I don&#8217;t want the job failing because of an error on one item, so I&#8217;m handing errors on an item-by-item basis and just continuing on with the next item.&#160; The net result of this, I soon found, is that my timer job actually says it ran successfully even if every single item fails.&#160; So I figured I would just set the &#8220;Failed&#8221; status on the timer job is anything went wrong so an administrator could see that not all was well.<\/p>\n<p>However, I quickly found that there is no way to set a timer job status.&#160; If you want the status to show up as &#8220;Failed&#8221; then the only way to do it is to throw an exception.&#160; 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. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been working with a bunch of custom timer jobs for last month.&#160; Basically, I&#8217;m processing a bunch of SharePoint items from the timer job and since I don&#8217;t want the job failing because of an error on one item, so I&#8217;m handing errors on an item-by-item basis and just continuing on with the&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3506","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3506"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3506\/revisions"}],"predecessor-version":[{"id":42134,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3506\/revisions\/42134"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3506"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}