Scheduled job condition check

jobin1
Tera Expert

Hi All

 

Whenever a new entry is created in u_custom_integration table with trigger status as "pending" I need to run a specific script through the OnDemand scheduled job. for achieving this I tried the below condition in the scheduled job but it's not considering the real-time entry details if there are multiple entries with trigger status as "pending"

How to solve this issue?

so as soon as a new entry is created in u_custom_integration table with trigger status as "pending" I need to run a custom script 

 

retrigger1();
function retrigger1() {
var answer = false;
var grcsi = new GlideRecord('u_custom_integration');
grcsi.addQuery('u_trigger_status', 'Pending');
grcsi.query();
var value = grcsi.getValue('sys_id');
gs.log("valueis "+ value);
if (grcsi.next()) {
var triggerstatus = grcsi.getValue('u_trigger_status');
if (triggerstatus =="failed"){
answer =true;
}

}
answer;
}

 

u_custom_integration table

jobin1_0-1668430006078.png

 

 

jobin1_1-1668430192340.png

 

 

3 REPLIES 3

Muhammad Khan
Mega Sage
Mega Sage

Why not try after insert business rule with condition trigger status as Pending?

Br already written this for retriggering mechanism

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @jobin1 ,

You can writedown Br after Insert

Condition trigger status is pending

Script :-

var rec = new GlideRecord('sysauto_script');
rec.get('name', 'YOUR_JOB_NAME_HERE');
SncTriggerSynchronizer.executeNow(rec);

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy