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

jobin1
Tera Expert

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

Ankur Bawiskar
Tera Patron
Tera Patron

@jobin1 

what's your business requirement?

you need to know which record should be queried with proper query conditions

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

the requirement is very difficult to explain actually  I just wanted to know how we can replace the gr.addQuery('sys_id', current.sys_id); in scheduled job run script as in br its works and gives the current record sys id 

@jobin1 

without knowing the requirement cannot help much

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have created an integration to crate Ritms through API and once the Ritm created through the BR I am sending back the ritm no and a few other details to u_custom_integration through the same BR.  for sending that I used the below query but its not working on the scheduled job, basically this scheduled job script  is similar to BR and its for triggering when the BR not run

 

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()) {