Templates in Service Portal - not working

dschneide
Kilo Contributor

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?

12 REPLIES 12

patrick_wilson
ServiceNow Employee
ServiceNow Employee

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.


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"));    


  }


}


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!


I don't see any link to the community thread you mentioned. Is there any news on templates support on service portal forms?