Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need Help Returning Values with GlideAjax

codechaser
Giga Expert

I need to populate a dropdown of courses, based-on the term selected. I have a GlideAjax call to fetch the data and then use the addOption() function to populate the value in the 'u_course' field.   However, I am unable to filer courses offered by 'u_term_code'... The same list of courses is populated, regardless of term selected.

What am I missing?

Grade_Change_Form.png

Client Script:

function onChange(control, oldValue, newValue, isLoading) {

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

return;    

}  

var ga = new GlideAjax('GetListValue');

ga.addParam('sysparm_name','getList');

ga.addParam('sysparm_term ', newValue);

ga.getXML(fillDetails);

function fillDetails(serverResponse){

var answer = serverResponse.responseXML.documentElement.getAttribute("answer");

var choiceval = answer.split(',');

for(var i = 0; choiceval.length > i ; i++){

g_form.addOption('u_course', choiceval[i], choiceval[i], [i]);

}

}

}

Client Callable Script Include:

var GetListValue = Class.create();

GetListValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getList : function() {

var courses = [];

var gr = new GlideRecord('u_bsu_courses');

gr.addQuery('u_term_code', this.getParameter('sysparm_term'));

gr.query();

while(gr.next())

courses.push(gr.name.toString());

return courses;

},

type: 'GetListValue'

});

12 REPLIES 12

Add a reference qualifier on course, something like:


javascript:"u_term_code=" + current.variables.u_term_code


Sorry for the delayed response, Michael.   Using the code, above as an advanced reference qualifier returns no courses.   However, I feel like this is on the right track, seeings how we are at least now filtering courses by term code.


Probably don't have the dependent variable correct.