GlideAjax Help - Service Catalog Reference Qualifier

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2011 09:59 AM
Hoping someone here can tell me what I'm doing wrong here. On a catalog Order Guide, I need to filter a list of Configuration Items based on the CI Class chosen in another variable.
I created an on Change Client Script (on the Class Variable) that calls a Script Include that "should" return all the results.
First Issue: The Include is answering the else if even though there is more than on CI for a given glass. See Screen Shot of Log entries.
Second Issue: I don't know how to get the Configuration Item list to use this Reference Qualifier. It never filters the list. I've tried javascript:GetAccMgtApps() and javascript:AccMgtApps() with and without semicolon on the ref qual field on that variable.
CS:
function onChange(control, oldValue, newValue, isLoading) {
if (!isLoading){
alert ('Class:' + newValue);
var ga = new GlideAjax('GetAccMgtApps');
ga.addParam('sysparm_name','AccMgtApps');
ga.addParam('sysparm_class_name', newValue);
ga.getXML(AccMgtAppsParse);
function AccMgtAppsParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
Script Include:
var GetAccMgtApps = Class.create();
GetAccMgtApps.prototype = Object.extendsObject(AbstractAjaxProcessor, {
AccMgtApps: function() {
var cis = '';
var cls = this.getParameter('sysparm_class_name');
gs.log("Class: " + cls);
var mod = new GlideRecord('cmdb_ci');
mod.addQuery('sys_class_name', cls);
mod.query();
while(mod.next()){
if(cis.length > 0){
//build a comma separated list if there is more than one answer
cis += (',' + mod.sys_id);
gs.log ('more than one:' + cis);
}
else{
gs.log ('only one:' + cis);
cis = mod.sys_id;
}
}
answer = 'sys_idIN' + cis;
gs.log ('Answer:' + answer);
return answer;
},
_privateFunction: function() { // this function is not client callable
}
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2011 02:19 PM
Ok. So it was that the answer.length was not working and found a workaround on the forum for creating a counter instead. Now I can get my onChange script to run the Ajax and return all the CIs for the Class that was chosen. For Example: Answer:sys_idIN,106c5c13c61122750194a1e96cfde951,1072335fc611227500c0267a21be5dc5,14a9e27bc61122750037b90c4d34da38,27e52cc8c0a8000b0067d0b66b8a66de,27e59e75c0a8000b003b3fab4211d2c2,27eabc4bc0a8000b0089fd512b3e8934,3a63d606c611222500487ae00a5bf3b8,6cabe993c611222500bb025775ec8732,6cb10db5c611222500bf34f43d2ff189,6ccab11cc611222500e1549797d1c1e5,827b692d0ad337021abb72d3737ff401,8d6916edc611222501dbb12bd683e36f,a9c68505c6112276017ee7d52f43e7c6,b0c25d1bc0a800090168be1bfcdcd759,b0c3437ac0a8000900433b8a412966aa,b0c4030ac0a800090152e7a4564ca36c,b0cb50c3c0a8000900893e69d3c5885e,b0cbf176c0a80009002b452bc33e2fc3,b0ccabf1c0a80009001f14fd151d8df0
Now the problem remains that on the Catalog Item I choose the "CI Class" and the "Configuration Items" variable doesn't filter. I currently have "javascript:GetAccMgtApps();" on the Reference Qual field of the "Configuration Item" reference variable but it's not updating the list to the 'answer' above.
Based on what I've read this should be the way to do it but it seems I need to take the 'answer' from my onChange and do something with it. I can't find any information on this.