Record Producer to generate Template and Scheduled Job all in one step

Daniel Shock
Kilo Sage

I am trying to create a record producer to give the ability to create a template and schedule a job based on that template all in one step.  I am able to create the template.  And I am able to create the scheduled job.  But, I can't seem to fill the reference field in the scheduled job that links the two.  The column name is template and the label is 'Generate This'.

I've been modifying and modifying this script in background to see if I can set the template on the scheduled job...so far no luck.

 

var si = 'ba828c931b520150423b4111cd4bcbf9';//sys_id of scheduled job
var grit = new GlideRecord("sysauto");//table containing scheduled jobs
grit.addQuery('sys_id', 'ba828c931b520150423b4111cd4bcbf9'); //sys_id of scheduled job
grit.query();

if(grit._next()){
	var genthis = '35724c931b520150423b4111cd4bcb5b'; //sys id of template
	gs.print('FacPMItem genthis variable = ' + genthis);
}
gs.print(grit.sys_id);
gs.print(grit.template);
gs.print('FacPMItem genthis variable = ' + genthis);
grit.template = '35724c931b520150423b4111cd4bcb5b';// sys id of template
grit.active = 'true';
grit.update();
gs.print(grit.template);

 

any suggestions or thoughts would be awesome.

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

As far as I can tell, OOB table sysauto has no field named template (or labelled Template). Are you sure your instance sports such a field on that table?

View solution in original post

3 REPLIES 3

-O-
Kilo Patron
Kilo Patron

As far as I can tell, OOB table sysauto has no field named template (or labelled Template). Are you sure your instance sports such a field on that table?

Hi- thanks, yes it's a reference field.  The label is 'Generate this' the name is template.  I've attached a screenshot.

 

find_real_file.png

after looking at it again with FRESH eyes... you are 100% correct.  I feel dumb!

 

The actual table is: sysauto_template