is there a way to Apply an incident template based on caller location

kimstorey
Kilo Contributor

I have an Incident for Hardware Issues, and based on the caller Location they default to a different Assignment Groups.

I want to apply a template which has different information for the Help Desk based on the Caller Location.

Example is:

Caller in Australia needs to contact xxx and call needs to be closed

Caller in NZ ticket needs to be assigned to the Assignment Group

I would like the template to apply information based on when the Caller Location is eg. AU

Does anyone know if this is possible?

5 REPLIES 5

vinitha3
Tera Guru

Yes.. I think you can use client script "onload" or "onchange" to apply the template,



current.applyTemplate("<template name>");




Refer : Creating a Template - ServiceNow Wiki  


How to apply an Incident template to an Incident Record Producer?



Thanks,


Vinitha.K


vab_13
ServiceNow Employee
ServiceNow Employee

You can apply a template in a client script.


leverage:   applyTemplate(template_sys_id);


Scripted templates



Have a read of this:


https://www.servicenowguru.com/system-definition/advanced-templates/




Mark your feedback( Like or Helpful or Correct) as per the impact of my response. Cheers!


Vab


asit2
Kilo Expert

Here is my solution-



create one onload client script on incident named: Choose Template By Location


Code:-


function onLoad() {


    //Type appropriate comment here, and begin script below



var location=new GlideAjax('Get_Location_By_UserID');


var str_location='';


//alert('g_user.userID '+g_user.userName);


location.addParam('sysparm_name','GetLocation');


location.addParam('sysparm_userid',g_user.userName);


location.getXMLWait();


str_location=location.getAnswer();


//alert('applying template for:'+g_user.location);


//current.applyTemplate(" IncidentTemplateForKolkataLocation");


alert('str_location:'+str_location);


if(str_location=='Paris')       // template will be applied for user with location Paris


{


      applyTemplate('155224634f23320073f9cab18110c77f');     // Sys_id of your template


}


   


}




Create one client callable script include named : Get_Location_By_UserID


Code:-


var Get_Location_By_UserID = Class.create();


Get_Location_By_UserID.prototype = Object.extendsObject(AbstractAjaxProcessor, {


GetLocation:function(){


var userid=this.getParameter('sysparm_userid');


//gs.addInfoMessage('userid'+userid);


var location='';


var rec=new GlideRecord('sys_user');


rec.addQuery('user_name',userid);


rec.query();


rec.next();


location=rec.location.name;


//gs.addInfoMessage('location'+location);


return location;


},


      type: 'Get_Location_By_UserID'


});


Jochen Geist
ServiceNow Employee
ServiceNow Employee

Did you already try the platform feature "Assignment Rule" for this? (Create an assignment rule)



I dont think your requirements justify using scripting instead of an OOTB feature.