script include not getting called by client scripts

Devika3
Tera Guru

Hi All,

We are trying to call a script include from catalog client script in HR scope. But the script include is not at all executing. 

Client script :

 

g_form.clearOptions('u_subcategory');
g_form.addOption('u_subcategory','','-- None --');

var Ajax = new GlideAjax('sn_hr_core.subcategoryPopulationHR'); //sn_hr_core.incidentTypeChoicePopulation2
Ajax.addParam('sysparm_name','populateSubCategoryHR');
Ajax.addParam('sysparm_category',newValue);
Ajax.getXML(populate1);
function populate1(response)
{
var answer1 = response.responseXML.documentElement.getAttribute("answer");
alert('test1' + answer1);
var str="";
str=answer1+'';
var choice = str.split(',');
for(var i=0;i<choice.length;i=i+2)
{
g_form.addOption('u_subcategory',choice[i+1],choice[i]);
}
}
}

 

 

script include:

var subcategoryPopulationHR = Class.create();
subcategoryPopulationHR.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

populateSubCategoryHR : function(){
gs.log('hrtest 1' + gp.getRowCount());
var choice='';var i=0;
var category=this.getParameter('sysparm_category');

var gp=new GlideRecord('sys_choice');
gp.addQuery('inactive',false);
gp.addQuery('dependent_value',category);
gp.addQuery('dependent_value',cat);
gp.addQuery('name','sn_hr_core_case');
gp.addQuery('element','u_subcategory');
gp.orderBy('value');
gp.query();
gs.log('hrtest 2' + gp.getRowCount());
while(gp.next())
{
gs.log('hrtest 3' + gp.getRowCount());
if(i==0)
choice=gp.label;
else
choice=choice+','+gp.label;
i++;
choice=choice+','+gp.value;
i++;
}
return choice;

},

type: 'subcategoryPopulationHR'
});

 

Not only the above, all the script include are not getting called by the client scripts.

Any help is appreciated.

Regards,

Devika.

7 REPLIES 7

johnfeist
Mega Sage
Mega Sage

Hi Devika3,

The typical reason why a script include is not responding to an AJAX call is that the SI is not client enabled.  You need to establish that when you first create the SI.  The check box is at the top right of the SI display.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

That one is enabled already.

that is already checked

Amit Gujarathi
Giga Sage
Giga Sage

Hi Devika,

Hope you are doing great.

The issue could be due to incorrect scope in the Script Include or a permission issue. Check the script Includ for the correct scope and make sure that the user has the necessary permissions to execute the Script includ.

Or the Script is not client callable.
Please enable the debugger once on the script include and see if you get some trace out there.

 

Regards,

Amit Gujjarathi




Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi