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

Not applicable

As HR is custom app, you might need to add records in the cross scope table.

But you surely need to have your AJAX set as this screenshot:

JoroKlifov1_0-1675784128669.png

 

-O-
Kilo Patron

Is the Script Include in a scope (any)?

If yes (and judging by the Client script it is), then line

gs.log('hrtest 2' + gp.getRowCount());

and

gs.log('hrtest 3' + gp.getRowCount());

will cause errors.

gs.log() is not available in scopes, you have to use gs.info() (or gs.error() or gs.warn()).

-O-
Kilo Patron

On the other hand Lookup Select Boxes support reference qualifiers and you can achieve the same results using that.