Execute a scheduled job after an Import is processed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 05:24 AM
I am trying to trigger to execute a scheduled job to run immediately. Upon completion the script should call and execute the scheduled job but its not working.
Can anyone assist me in accomplishing this, below is the script I am using
(function runTransformScript(source, map, log, target) {
// Define the name of the scheduled job
var scheduledJobName = 'Scheduled Execution of Dell Asset Import Automation';
// Query the sysauto_script table for the scheduled job
var scheduledJob = new GlideRecord('sysauto_script');
scheduledJob.addQuery('name', scheduledJobName); // Match by job name
scheduledJob.query();
if (scheduledJob.next()) {
// Use GlideScheduleWorker to execute the job immediately
var jobId = scheduledJob.sys_id.toString();
gs.print('Found scheduled job. Executing job ID: ' + jobId);
// Execute the job
var worker = new GlideScheduleWorker(jobId);
worker.start();
} else {
gs.print('Scheduled job not found: ' + scheduledJobName);
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 05:56 AM - edited 01-10-2025 05:57 AM
Hi @GChanner,
Are you implementing this as an onComplete 'Transform Script'?
If not, this is exactly what these are for...
For sample code as to how to trigger the Scheduled Job, see below:
var schedJobGR = new GlideRecord('sysauto_script');
schedJobGR.addQuery('name','Test Scheduled Job'); // The name of the scheduled job
schedJobGR.query();
if(schedJobGR.next()){
SncTriggerSynchronizer.executeNow(schedJobGR); // use syntax for global scope
//gs.executeNow(schedJobGR); // use this syntax for scoped app
}
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 08:33 AM
Hi Robbie,
Thanks for jumping in. I am doing this 'onComplete' in the transform script.
I tested it in the background script and got the following:
Evaluator: com.glide.script.RhinoEcmaError: "source" is not defined. script : Line(13) column(0) 10: //gs.executeNow(schedJobGR); // use this syntax for scoped app 11: } 12: ==> 13: })(source, map, log, target);
Thanks
Garfield