List of possible ways to call script include function

Pari5
Tera Contributor

Hi All,

I have a script include which runs every time when the new change request is created. But I couldn't find where it is called from. I have checked in client scripts, business rules, UI action and catalog client scripts. 

Can you please let me know the possible ways to call script include.

Thanks in advance.

1 ACCEPTED SOLUTION

Hi Parimala,

As an admin can you enable debugging and then create new record; it will show what all business rules are being triggered. Also can you check whether that field has calculated value and that script include function is called in from the dictionary level?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Hi Parimala,

As an admin can you enable debugging and then create new record; it will show what all business rules are being triggered. Also can you check whether that field has calculated value and that script include function is called in from the dictionary level?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks much for your effort Ankur!

Finally got it resolved. Script include call has been defined inside dictionary entry override in default value field.

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

check first if the Script Include is client callable. By default a Script Include is server side.

Use the following guide, it will help you:

https://codecreative.io/blog/glideajax-troubleshooting-guide/

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Priyanka Pednek
Kilo Guru

Hi,

Script Include: (Ensure the client callable checkbox is checked)

var getStandardFields = Class.create();

getStandardFields.prototype = {

getFields : function() {

var stdChange = this.getParameter('sysparm_std_change');

var standardFields = new GlideRecord('u_standard_changes');

standardFields.addQuery('sys_id', stdChange);

standardFields.query();

if(standardFields.next()) {

return standardFields.u_short_description + '|' + standardFields.u_description;

} return '';

 },

 type: 'getStandardFields'

};

 

 

 

 

 

Client script:

unction onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue == '') {return;

}

 

 //Type appropriate comment here, and begin script below

 

  var classificationType = g_form.getValue('u_change_classification');

if (classificationType == 'Standard') { //MAke server call only if the type is Standard

var ga = new GlideAjax('getStandardFields');//this is the script include

ga.addParam("sysparm_name", "getFields"); //this is the function within the script include

ga.addParam("sysparm_std_change", g_form.getValue('u_standard_change_num'));

ga.getXML(getResponse);

 

}

function getResponse(response) {

var values = response.responseXML.documentElement.getAttribute('answer').toString().split('|');

 g_form.setValue('short_description', values[0]);

 g_form.setValue('description', values[1]);

}

}

 

Also,  you must extend abstractajaxprocessor

'The sys_script_include code must extend the AbstractAjaxProcessor class and be client-callable.'

Check below link

GlideAjax - ServiceNow Wiki

 

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks