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

What is the case when BR will not run?


Raghav
MVP 2023

@jobin1 

you created an integration to create RITM through API and then BR on RITM table is written to push RITM data to custom table.

Since you created an API some external team will use it.

how schedule job come into picture?

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

Br is to create ritm and push back few data to the custom int table and once the payload is sent those info will be saved in the custom int table if response is not received from BR status will be pending and I will run the scheduled job at that time only

@jobin1 so in this case you can follow the below approach:

1. Fire an event incase the response is not received from BR in which you can pass current record. (using gs.eventQueue() method).

2. create a script action which will run when event is fired and write your code in the script action instead of scheduled job.


Raghav
MVP 2023

David Whaley
Mega Sage

What is the qualification your business rule is executing on?  I would think that would need to be added in your query instead of sys_id.  You would probably also need to get the most recent.