When template is not loading in new change request when i passing the template sysid in proprty

Mounika B1
Tera Contributor

Hi Team ,

Am trying to load the template when change request is new and category is empty.
when i have passed the template sys_id is working  which is not acceptable.

I have tried to pass the template mysid in system property and called in client callable script include now it is not working below is my code. Please any inputs for the solution or guide me i did any mistake.
client script & script includes.

Thanks,
Mounika B

 

 

3 REPLIES 3

Tanushree Maiti
Kilo Patron

Hi @Mounika B1 ,

 

After line 10,  add a alert

Line 11: alert (response); 

 

If line 11 return template sys_id , then Comment  Line 12, try/catch is not needed.

 

Replace Line 16 

from 

g_form.applyTemplate(templateSysId);

 To:

applyTemplate(templateSysId);
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Hi Thanusree,

Thanks for the response.I have tried as per given suggestion but still no out put.i did not get any alert messgage on the form.

function onLoad() {
    var category = g_form.getValue('category');
  if (g_form.isNewRecord() && category == "") return;
   var changeType = g_form.getValue('type');
    if (changeType == 'normal' || changeType == 'emergency' || changeType == 'expedited')
    return;
    var ga = new GlideAjax('GetNGUserProperty');
    ga.addParam('sysparm_name', 'getDefaultChangeTemplate');
    ga.getXML(function (response) {
        var templateSysId = '';
        alert (response);
        try {
            templateSysId = response.responseXML.documentElement.getAttribute('answer') || '';
        } catch (e) {}

        if (templateSysId) {
            applyTemplate(templateSysId);
        }
    });
}




Mounika B1
Tera Contributor

Hi Team ,
can any one help me why after passing the after passing the  template sys_id in system property  and calling into script includes it is not working .if pass the sysid directly in client side it is working . May i know the case.is there anything i missed in script.