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 11:53 PM - edited 12-07-2022 11:55 PM
@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.
ServiceNow Community Rising Star, Class of 2023