- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2016 03:06 PM
Everyone,
I need to apply a specific template on and
I ´m trying to use the applyTemplate method by using a GlideRecord variable, and initialize it after declaring it but it is not working any ideas?
Got information from Scripted templates
see bellow:
Onclick: btemps
function () btemps {
var rec1 = new GlideRecord("incident");
rec1.initialize();
rec1.applyTemplate("my_incident_template");
}
--
Thanks
Miguel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2016 04:45 PM
That is the code to apply templates is server side and won't work on a client side UI action.
The code you have given is client side; current.applyTemplate will not work. There is also some syntax issues.
The code below should work for you
function btemps () {
applyTemplate(sys_id_of_my_incident_template);
}
Apply Template on Field Change — ServiceNow ELITE.com
Just a heads up - similar functionality to what you are asking for is available in Geneva.
There is a new Template bar at the bottom of each form and you can click on any template from there to populate the form.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2016 04:45 PM
That is the code to apply templates is server side and won't work on a client side UI action.
The code you have given is client side; current.applyTemplate will not work. There is also some syntax issues.
The code below should work for you
function btemps () {
applyTemplate(sys_id_of_my_incident_template);
}
Apply Template on Field Change — ServiceNow ELITE.com
Just a heads up - similar functionality to what you are asking for is available in Geneva.
There is a new Template bar at the bottom of each form and you can click on any template from there to populate the form.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 06:21 AM
Hey Paul, it worked as expected.. it ´s kind of tricky to know when you need to add sys_ids ´s to methods so they work..
Thanks for your help!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2016 03:45 PM
Found your link really helpful for my simple task of trying to apply a template based on subcategory.
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2016 04:52 PM
Hi Miguel,
You may find the below thread helpful.
http://www.servicenowguru.com/system-definition/advanced-templates/