//查询表格,取得去重复的name
var queryPro = Class.create();
queryPro.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
queryPro_info:function(){
var answer;
var gr = new GlideAggregate('x_178251_my_applic_mypro');
gr.groupBy('bname');
gr.query();
while(gr.next()){
answer=this.newItem("ans");
answer.setAttribute('q_bname',gr.bname);
}
},
type: 'queryPro'
});
//将查询到的去重后的name塞到select box中
function onLoad() {
//Type appropriate comment here, and begin script below
var ga=new GlideAjax("queryPro");
ga.addParam("sysparm_name","queryPro_info");
ga.getXML(callback);
var b_name='';
function callback(response){
var answer=response.responseXML.getElementsByTagName("ans");
for(var i=0;i<answer.length;i++){
b_name=answer[i].getAttribute('q_bname');
g_form.addOption("bPro",b_name,b_name);
}
}
}
//根据选择的name值再次查询
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var bPro_value=g_form.getValue("bPro");
var ga=new GlideAjax("addPro");
ga.addParam("sysparm_name","addPro_info");
ga.addParam("sysparm_getbname",bPro_value);
ga.getXML(callback);
function callback(response){
var answer=response.responseXML.getElementsByTagName("res");
g_form.clearOptions("mPro");
for(var i=0;i<answer.length;i++){
var mPro_value=answer[i].getAttribute('q_mname');
//alert(answer[i].getAttribute('q_mname'));
g_form.addOption("mPro",mPro_value,mPro_value);
}
}
//Type appropriate comment here, and begin script below
}
//根据前台得到的select box的值,再次查询表格得到要联动的select box的值
var addPro = Class.create();
addPro.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
addPro_info:function(){
var b_name=this.getParameter("sysparm_getbname");
var gr=new GlideRecord('x_178251_my_applic_mypro');
gr.addQuery("bname",b_name);
gr.query();
while(gr.next()){
var result=this.newItem("res");
result.setAttribute('q_mname',gr.mname);
}
},
type: 'addPro'
});