How to set up condition to only run Scheduled Job if Previous Scheduled Job was succesful

bpolo
Tera Guru

We want to run a scheduled job only if a previous scheduled job was succesful. Is there a way to check to see if a scheduled job was succesfully run for the day, so that when the second scheduled job starts running, a condition can be set to only continue if the previous job was succesful? 

Thanks in advance!

1 ACCEPTED SOLUTION

Weird
Mega Sage

You could try triggering the other job at the end of the first one with this:

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

 https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/time/referen...

 

So adding that to the end of your script would require the script to finish first. Just add any conditions you might have to recognize the first script did what it had to do.

View solution in original post

2 REPLIES 2

Weird
Mega Sage

You could try triggering the other job at the end of the first one with this:

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

 https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/time/referen...

 

So adding that to the end of your script would require the script to finish first. Just add any conditions you might have to recognize the first script did what it had to do.

Thank you very much for this solution!