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

In that case you can use fix scripts, Fix scripts are on demand scripts that can be manually triggered and they can be moved between instances via update sets too.

 

The only reason im suggesting not to use script includes is that script includes are not triggered unless they are called form somewhere. they are a collection of functions which has to be called/invoked form somewhere, so if you use script include you will need to write another code that will call the script include.

-Anurag

thomaskennedy
Tera Guru

I'm not sure I understand why a script include would be involved here. If you have a Scheduled Script Execution (sysauto_script) where Run is set to Once, you can go find that row using GlideRecord and set its run_start to whatever. The SSE would then run whatever code you tell it to.

To set the SSE to run ten seconds in the future the code would be something like this:

 

var gdt = new GlideDateTime();
gdt.addSeconds(10);
gr.setValue("run_start",gdt.getDisplayValue());

The script include would have testing it - the goal is to test the scheduled job script and capture that in an update set -- does that clarify it?