Testing a scheduled job script via script include

Dameli Utembaye
ServiceNow Employee
ServiceNow Employee

Hi, I am tying to write a script include to test a script in a scheduled job.

Looking for some examples, helpful resources. 

 

Here is all I have in the testing script thus far 

var testScript = Class.create();
testScript.prototype = {
initialize: function() {
},

type: 'testScript'
};

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

HI,

What are you trying to achieve?

Script includes don't run by themselves unless invoked form somewhere. If you want to run a scheduled job by some server side script you can do so by creating a fix script or background script and use the code below to trigger a scheduled job.

var schImp_GR = new GlideRecord('sysauto');
schImp_GR.addQuery('name','<name>'); // Name of the scheduled job
schImp_GR.query();
if(schImp_GR.next()){
SncTriggerSynchronizer.executeNow(schImp_GR); // this is for global scope
}

 

If your scheduled job is on demand then you can just trigger it manually also by clicking the 'execute now' button.

-Anurag

I am trying to TEST a scheduled job(it has a script) -- so really I am probably trying to call that script from the script include -- any ideas/resources here?

You don't call a script or a function of a scheduled job, you can call the job as a whole to run from any server side script using the code I gave above.

Since this is just a test I would suggest you do it on background script

AnuragTripathi_0-1694621494092.png

 

-Anurag

what if i don't want to use a background script but I want to use a script include so it is captured in the update set for review later?