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 09:31 AM
Looks similar to a subcategory field where Term is the category. Are you getting a response now?
This like doesn't look right: for(var i = 0; choiceval.length > i ; i++){
Try this: for(var i = 0; i < subcats.length; i++) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 10:05 AM
Hi Michael and thank you for the reply. I made the change you suggested, above and am still returning all courses, no matter which term is selected.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 10:09 AM
Ok, try changing this line:
ga.addParam('sysparm_term ', newValue);
to
ga.addParam('sysparm_term ', g_form.getValue('u_term'));
where u_term is the name of your field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 10:14 AM
Thank you for the suggestion. Unfortunately, that did not work, either. I also tried ga.addParam('sysparm_term ', 'u_term_code'); with no result.