Rerun scheduled export jobs automatically

Abdul Azeem1
Tera Contributor

Hello,

We have few scheduled export jobs that runs on daily basis. Some jobs run successfully but some jobs failing with error. We can see the error in export logs as "Could not download file because: Socket error".

After manually running of this failed jobs they run successfully without error.

Is there any way to re-run the failed scheduled export jobs automatically ?

 

Appreciate your help!!

 

TIA,

Abdul Azeem

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can run a daily scheduled job may be 10-15mins after your scheduled reports.

Check if they failed with that error and then run them from script again

like this -> enhance this script as per your requirement

var rec = new GlideRecord("sysauto_report");
rec.get("scheduledReportSysId");

gs.executeNow(rec);

Regards
Ankur

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

Hi Ankur,

 

Thanks for you prompt reply.

May I know Is there any consequences of using gs.executeNow(); ?

 

Please suggest.

 

Kind regards,

Abdul Azeem

Hi,

Nothing as such.

It's an OOB code which allows you to run scheduled job/reports from script.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

MrMuhammad
Giga Sage

Hi @Abdul Azeem,

One way is to write the after update Business rule on sys_trigger table.  Set the trigger conditions correct to determine that it should run only on errors and for the required scheduled job.

use gs.executeNow(current) in the Business rule that will re-run the job.

Regards,

Muhammad

Regards,
Muhammad