Scheduled Job/Business rule not updating/getting correct recordsIssue <!-- div.margin{ padding: 10px 40px 40px 30px; } table.tocTable{ border: 1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); padding-top: .6em; padding-bottom: .6em; padding-left: .9em; padding-right: .6em; } table.noteTable{ border:1px solid; border-color:#E0E0E0; background-color: rgb(245, 245, 245); width: 100%; border-spacing:2; } table.internaltable { white-space:nowrap; text-align:left; border-width: 1px; border-collapse: collapse; font-size:14px; width: 85%; } table.internaltable th { border-width: 1px; padding: 5px; border-style: solid; border-color: rgb(245, 245, 245); background-color: rgb(245, 245, 245); } table.internaltable td { border-width: 1px; padding: 5px; border-style: solid; border-color: #E0E0E0; color: #000000; } .title { color: #D1232B; font-weight:normal; font-size:28px; } h1{ color: #D1232B; font-weight:normal; font-size:21px; margin-bottom:-5px } h2{ color: #646464; font-weight:bold; font-size:18px; } h3{ color: #000000; font-weight:BOLD; font-size:16px; text-decoration:underline; } h4{ color: #646464; font-weight:BOLD; font-size:15px; text-decoration:; } h5{ color: #000000; font-weight:BOLD; font-size:13px; text-decoration:; } h6{ color: #000000; font-weight:BOLD; font-size:14px; text-decoration:; } hr{ border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; } ul { list-style: disc outside none; margin-left: 0; } li { padding-left: 1em; } --> Overview You may have cases when you are trying to call business rule from schedule job to update some records but business rule is not updating correct records or not updating anything. This article will explain some ways to debug business rule in such cases. Example Lets take an example of 'Auto Cancel Change' scheduled job thats calling business rule, but somehow business rule is not getting the correct results or not updating the correct records. 1. First you need to make sure business rule script is getting triggered, to test this put some debug statements in your business rule. -- For example here is your script you have for 'Auto Cancel Change' business rule: function autoCancelChanges() { gs.print("I am Here inside Business rule"); ---------> To make sure you are in business rule script var ps = gs.getProperty('cv.change.autoclose.time'); var pn = parseInt(ps); var queryTime = new GlideDateTime(); queryTime.addDaysUTC(-pn); if (pn > 0) { gs.print("I am Here inside First IF condition"); ---------------> To make sure you entered in first IF condition pn has some value var gr = new GlideRecord('change_request'); gr.addQuery('state', '-5'); gr.addQuery('approval', 'not yet requested'); gr.addQuery('sys_created_on','>',gs.daysAgo(30)); gr.query(); while(gr.next()) { gs.print("I am Here inside When condition"); ---------------> To make sure query got any record from the conditions we have gr.state = '4'; gr.comments = 'Change automatically cancelled after ' + pn + ' days in the New state.'; gr.active = false; gr.update(); } } -- Once you kick off the job, open System Log --> All (syslog table) to make sure which log statements is printing. This will tell you if business rule is triggered and where it failed. 2. Now lets say your business rule is failed in while loop, it never entered in while loop. That means the query conditions did not bring back any results from database and conditions need to be reviewed. To review conditions run print Glide record query results in System Definition --> Scripts - Background. Here is the GR query you can run: var gr = new GlideRecord('change_request'); gr.addQuery('state', '-5'); gr.addQuery('approval', 'not yet requested'); var createddate = gr.addQuery('sys_created_on','>',gs.daysAgo(30)); gr.query();var numrecord=gr.getRowCount();gs.print("Number of Record Query is Getting :" + numrecord); Running this script is getting 0 records, here is the output: *** Script: Number of Record Query is Getting :0 -- Now remove conditions one by one to make sure which condition has issues. In this case issue is with approval condition: gr.addQuery('approval', 'not yet requested'); The value of approval 'not yet requested' is 'not requested' in choice list table. Make necessary change to query you are running and make sure you are getting some records now.. -- You can print more details to debug further details like 'gs.print(createddate);' to see if date you mentioned has the issues Additional Information 1. Here please read more about Scripts - background module: https://docs.servicenow.com/csh?topicname=c_ScriptsBackground.html&version=latest Important Notes from above doc: -- Administrators can use the Scripts - Background module to run arbitrary JavaScript code from the server. -- Running free-form JavaScript can cause system disruption or data loss. ServiceNow does not recommend running free-from scripts from a production instance. 2. Here you can read more about Glide API's: https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GS-minutesAgo_N