Need Help Returning Values with GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 08:31 AM
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?
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'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 11:59 AM
Add a reference qualifier on course, something like:
javascript:"u_term_code=" + current.variables.u_term_code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2018 11:01 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2018 11:38 AM
Probably don't have the dependent variable correct.