Alternate solution for current.sys_id in Scheduled job run script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 12:56 AM - edited 12-07-2022 02:35 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 06:23 AM
What is the case when BR will not run?
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 07:05 AM
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?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 10:08 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 11:09 PM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 06:39 AM
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.