how to trigger a scheduled job in the flow

Community Alums
Not applicable

I have an otb schedule job which runs daily. I had a requirement where the the scheduled job should execute from flow based on some conditions.
can anyone help me how to trigger a scheduled job inside the flow ?

 

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Community Alums 

https://www.servicenow.com/community/developer-articles/how-to-run-a-scheduled-job-from-flow-designer/ta-p/2696220

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Animesh Das2
Mega Sage

Hi @Community Alums ,

 

You can create a custom flow action having 'Script step' in it and in that script you can put below lines. Then just use that new action inside your flow.

 

 

var job = new GlideRecord('sysauto_script');
job.addQuery('name','That Schedule Job Name');
job.query();
if (job.next()) {
    SncTriggerSynchronizer.executeNow(job);
}

 

 

If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

what's your requirement to run scheduled job from flow?

You will have to use custom flow action and then use this script

var jobRecord = new GlideRecord('sysauto_script');
jobRecord.addQuery('name', 'Schedule Job Name');
jobRecord.query();
if (jobRecord.next()) {
    gs.executeNow(jobRecord);
}

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

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