Scheduled Job need to run by user manually

Sarah Bouil
Tera Expert
Hi, I have a scheduled job which will run every 6 months automatically. But one of the user requesting that they want to run or execute the same scheduled job by manually. It means they need to control or trigger the scheduled job when ever they want to do. Is it possible? If possible please let me know how to do it? As per my knowledge, admin role users can run or execute by clicking 'Execute Now' button. But my user doesn't have the admin role.
3 REPLIES 3

Sagar Pagar
Tera Patron

Hi @Sarah Bouil,

 

There are ways for this.

1) Inbound email action: Create inbound email actions and execute it by scripts.

2) Catalog item: create catalog item and execute it by  using workflow/ flows.

 

Sample scripts to trigger scheduled job.

var scheduleJob = new GlideRecord('sysauto_script'); // glide the Scheuled job table
scheduleJob.get("42f87abc2f37201002454ae72799b66f"); //Sys ID of your schedule job record

SncTriggerSynchronizer.executeNow(scheduleJob); //execute schedule job

 

For reference: How to invoke a scheduled job from inbound email action? 


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi Sagar,

 

Thank you for your reply. One of my user wants to execute the scheduled job and the user would like to manually control the triggering. Which one is easy and best way to do it among above two options. Please help me with the detailed scripts.

Hi @Sarah Bouil,

 

Catalog item option is easy to impalement using flows/ workflow. Sample scripts have shared in above reply. It is also easy to track and troubleshoot in case have any issues.

 

Run script activity:

var scheduleJob = new GlideRecord('sysauto_script'); // glide the Scheuled job table
scheduleJob.get("42f87abc2f37201002454ae72799b66f"); //Sys ID of your schedule job record

SncTriggerSynchronizer.executeNow(scheduleJob); //execute schedule job


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow