Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Create Template from Script

Dan Tolgyesi1
Tera Expert

Hi,

Does anyone know if there is anyway that I can create a template "sys_template" from a business rule populating the template field using values from a from on a table?

I have created an "Event Management" Table with an Event Task table. Sometimes event tasks need to be schduled so I need to be able to create a scheduled job (Which I have managed to do via a business rule) and create a template for "Event Task" and fill in the template fields.

Thanks in advance for any help
Dan

6 REPLIES 6

You have to join javascript variables with the string. Try this:



var etask = new GlideRecord("sys_template");

etask.initialize();
etask.table = 'u_event_task';
etask.name = current.number + " - Event Task";
etask.short_description = current.u_task_title;
etask.template ='assignment_group=' + current.u_task.resolver_group +'^short_description=' + current.u_task_title + '^description=' + current.u_task_description + '';

etask.insert();


Hit the Thumb Icon and/or mark as Correct, if my answer was correct. So you help others to see correct responses and I get fame 🙂

Cheers,
Kostya

Thank you very much, I was close, I just had the '^' in the wrong place.

All good now 🙂

Thanks for your help

Cheers
Dan