Alternate solution for current.sys_id in Scheduled job run script

jobin1
Tera Expert

Hi All,

 

The below code is working in BR but not in a scheduled job so what is the best way to replace gr.addQuery('sys_id', current.sys_id); in a scheduled job run script?

 

var gr = new GlideRecord('u_custom_integration');
 gr.addQuery('sys_id', current.sys_id);//not considering in scheduled job run script
 gr.setLimit(1);
 gr.query();
 if (gr.next()) {

//tried gr.addQuery('sys_id', getUniqueValue()); but not working

@Ankur Bawiskar Any idea?

 

15 REPLIES 15

jaheerhattiwale
Mega Sage
Mega Sage

@jobin1 current object is only accessible in business rule not in scheduled job. So please before using current you can gliderecord on  that table, as below

 

var current = new GlideRecord("<TABLE ON WHICH BUSINESS RULE IS WRITTEN>");

current.addQuery("<ENCODED QUERY HERE FOR FILTERING>";

current.query();

 

while(current.next()){

//Do logic here

}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023