Create Discovery Schedule from run Script

Austin Rion1
Tera Contributor

I am working on a workflow to automate the onboarding of AWS Cloud management. I am trying to create a Run script in my WF that will create a Discovery schedule, I am struggling to find the correct syntax to add the "time" via the script. 

find_real_file.png

Any help would be appreciated! 

1 ACCEPTED SOLUTION

Ok, so looking at the discovery_schedule table, run_time is a GlideTime.

Based on that, and a little tinkering, I think I would do this:

var SECS = 1000;
var MINS = 60 * SECS;
var HOURS = 60 * MINS;
disSched.run_time = new GlideTime(5 * HOURS).getValue();

or

var gt = new GlideTime();
gt.seValue("05:00:00");
disSched.run_time = gt.getValue();

View solution in original post

5 REPLIES 5

tim_broberg
ServiceNow Employee
ServiceNow Employee

Can we see what your script looks like so far?

 

// Insert values in AWS Discovery Schedule
if (workflow.scratchpad.aws.account_cred_sys_id) {
	var disSched = new GlideRecord('discovery_schedule');
	disSched.initialize();
	disSched.name = workflow.scratchpad.aws.account_name;
	disSched.discover = 'Web Service';
	disSched.disco_run_type = 'daily';
	disSched.run_time = 
	disSched.insert();
	
	workflow.scratchpad.aws.discoverySchedule_sys_id = disSched.sys_id;
	

I am specifically struggling to find the syntax for how to format the "run_time"

Ok, so looking at the discovery_schedule table, run_time is a GlideTime.

Based on that, and a little tinkering, I think I would do this:

var SECS = 1000;
var MINS = 60 * SECS;
var HOURS = 60 * MINS;
disSched.run_time = new GlideTime(5 * HOURS).getValue();

or

var gt = new GlideTime();
gt.seValue("05:00:00");
disSched.run_time = gt.getValue();

gah. gt.setValue.

Somehow the 't' escaped.