Testing a scheduled job script via script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 08:52 AM
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 09:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 09:06 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 09:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 09:13 AM
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?