- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:59 AM
Is there a URL that can trigger a scheduled job (on demand) to run, so I can trigger a script to run from an external system that will send a HTTP get to ServiceNow, with the name of the script (scheduled job)?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2014 09:36 AM
All great answers thanks. In case anyone is interested I went with a processor.. Processor name and parameters set to "EX".
Code follows..
// remotely execute a scheduled job, restricted to admin only
(function(){
if(!gs.hasRole('admin')) return;
var name = g_request.getParameter("name");
var scriptname = new GlideRecord('sysauto_script');
scriptname.get('name', name);
if(!scriptname) return;
SncTriggerSynchronizer.executeNow(scriptname);
g_processor.writeOutput('','ok ');
})();
call like so https://instance.service-now.com/?EX&name=<script>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 12:56 PM
Hi Chris,
How would you deal with authentication from the external system?
Here's an idea on how to do it (once the user is authenticated):
- Create a new table (e.g. u_run_job) that will log a record every time the external system calls the URL.
- Include a reference field for the scheduled job to run (e.g. u_scheduled_job).
- Create a Client Script onLoad that reads the value for the schedule job reference id and saves the record.
- From the external system (or from a browser for testing purposes), call the URL as follows:
https://<instance name>.service-now.com/nav_to.do?uri=u_run_job.do?sys_id=-1%26sysparm_query=u_scheduled_job=<job_id>
It is not required to create a new record every time but I think it could be a good idea to have a log.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 12:59 PM
I don't think this functionality exists by default, but you could pretty easily write a ui page that accepts a url parameter and triggers a scheduled job.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 01:09 PM
Hi Chris,
You could also do it using Direct Web Services.
1 ) Create a new boolean field on scheduled jobs, say "Run now".
2 ) Write a BR that will run the job on change of Run now field.
3 ) Using SOAP / REST you can update the scheduled job record's run now field.
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2014 09:36 AM
All great answers thanks. In case anyone is interested I went with a processor.. Processor name and parameters set to "EX".
Code follows..
// remotely execute a scheduled job, restricted to admin only
(function(){
if(!gs.hasRole('admin')) return;
var name = g_request.getParameter("name");
var scriptname = new GlideRecord('sysauto_script');
scriptname.get('name', name);
if(!scriptname) return;
SncTriggerSynchronizer.executeNow(scriptname);
g_processor.writeOutput('','ok ');
})();
call like so https://instance.service-now.com/?EX&name=<script>