Load a template based on a field value

jagannaths
Kilo Expert

Hi,

We have a requirement to load a template on new_call table which sets the description field to some value. This template has to load when a field "Call Type" changes to incident. I am trying to write an onChange client script using applyTemplate("<template name>"). But it does not work.

Has anyone implemented something similar?

Thanks!

7 REPLIES 7

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Perhaps this blog post I wrote would give you an idea:



Using incident templates direct from calls



//Göran


Hi Goran,



Thank you for your quick response. I am going to try it out. However, the requirement I have is a little different. We would want the template to load on the new_call table itself as soon as the call type is set to incident. Is there a way to do that?



Thanks!


Did you manage to solve this? How?

I'm looking for the exact same thing at the moment.

Hi Henrik,

 

I saw I missed her reply for 3 years ago, but do I get it right with that you want to load add apply a template on the call form when call type is changed to incident? 

If this is the case I just created a template on the call table, went to sys_template and got the sys_id of the template record. Then I created a onChange client script on the call type field with this code.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	if (newValue == 'incident')
		applyTemplate('4ec1855c130f2b40a52c721a6144b04a');//The sys_id of the template I created on call table.
 }
//Göran
Feel free to connect with me: