Templates in Service Portal - not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 01:55 AM
We want to use the templates in service portal forms. Is it possible to show the template bar in the service portal?
Since I didn ´t find any solution, I made a new reference field and used the applyTemplate() function like described here - Apply Template on Field Change — ServiceNow Elite. This is also not working in the ServicePortal.
We get the following error:
(g_env) [SCRIPT:EXEC] Error while running Client Script "Load Template": ReferenceError: applyTemplate is not defined
_logError @ js_includes_sp.jsx:63723
Any ideas how to get templates working in service portal?
- 3,334 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 11:37 AM
Hi there!
applyTemplate isn't a standalone function - it's actually a method on GlideRecord. Are you calling the function like this:
gr.applyTemplate();
In fact, it would be most helpful if you posted the contents of your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2017 12:23 AM
Hi Patrick,
below is the client script. It is working - but not in service portal.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue != "") {
applyTemplate(g_form.getValue("u_template"));
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2017 12:36 AM
I investigated, and it looks like the applyTemplate API is not supported in Service Portal today. I've made a note of it, and I've added it to our backlog for consideration. Thank you for bringing this to our attention!
If you're interested in chasing down a workaround, I found this thread on Community that talks about using applyTemplate from a server side GlideRecord by calling into a business rule/server script. You may find some success in that direction
Best of luck!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2018 06:51 AM
I don't see any link to the community thread you mentioned. Is there any news on templates support on service portal forms?