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.
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:
var gr = new GlideRecord('change_request');
gr.addQuery('approval', 'not yet requested');
var createddate = gr.addQuery('sys_created_on','>',gs.daysAgo(30));
gs.print("Number of Record Query is Getting :" + numrecord);
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
1. Here please read more about Scripts - background module:
Important Notes from above doc:
2. Here you can read more about Glide API's: