Based on level3 value, level 4 choice list values will be populated.
Based on level4 value, level 5 choice list values will be populated.
Based on level5 value, level 6 choice list values will be populated.
Below is the script include.
BusinessGroup : function(){
gs.log(" level3 in si"+level3)
var choices=[];
var gr= new GlideAggregate('u_ehsvelocities');
gr.groupBy('u_business_group');
gr.query();
while (gr.next()){
gs.log(" level3 in si in loop"+gr.u_business_group);
choices.push (gr.getValue('u_business_group').toString());
}
//return JSON.stringify(choices);
return 'sys_idIN' +chocies;
},
BusinessUnits : function(BusinessGroup){
gs.log(" level4 business Unit"+ BusinessGroup );
var unitchoices=[];
var gr= new GlideRecord('u_ehsvelocities');
gr.addQuery('u_business_group',BusinessGroup);
gr.query();
while (gr.next()){
gs.log(" level4 in while loop"+gr.u_business_unit);
unitchoices.push (gr.getValue('u_business_unit').toString());
}
return 'sys_idIN' +unitchoices;
},
WorldArea : function(BusinessGroup, BusinessUnits){
gs.log("level5 WorldArea " );
var worldareas=[];
var gr= new GlideRecord('u_ehsvelocities');
gr.addQuery('u_business_group',BusinessGroup);
gr.addQuery('u_business_unit',BusinessUnits);
gr.query();
while (gr.next()){
gs.log(" level5 in while loop"+gr.u_world_area);
worldareas.push (gr.getValue('u_world_area').toString());
}
return 'sys_idIN' +worldareas;
},
getCountry : function(){
gs.log("level6 Country " );
var businessGroup=this.getParameter('sysparm_business_group');
var businessUnits=this.getParameter('sysparm_business_unit');
var worldArea=this.getParameter('sysparm_word_area');
var buflexCountry=[];
var gr= new GlideRecord('u_ehsvelocities');
gr.addQuery('u_business_group',businessGroup);
gr.addQuery('u_business_unit',businessUnits);
gr.addQuery('u_world_area',worldArea);
gr.query();
while (gr.next()){
gs.log(" level6 in while loop"+gr.u_bu_flex);
buflexCountry.push(gr.getValue('u_bu_flex').toString());
}
//return 'sys_idIN' +buflexCountry;
return buflexCountry.join(',');
and below is my client script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert("1");
//Type appropriate comment here, and begin script below
var level3BusinessGroup=g_form.getValue('location_of_role_assignment_as_in_the_location_tree_level_3');
var level4Businessunit=g_form.getValue('location_of_role_assignment_as_in_the_location_tree_level_4');
if(!level3BusinessGroup||level4Businessunit){
return;
}
alert("before entering the loop");
var ga= new GlideAjax('GetBusinessUnitsByBusinessGroup');
ga.addParam('sysparm_name','getCountry');
ga.addParam('sysparm_business_group','level3BusinessGroup');
ga.addParam('sysparm_business_unit','level4Businessunit');
ga.addParam('sysparm_word_area',newValue);
ga.getXMLAnswer(function (response){
alert("in response");
var buflexCountry=response.split(',');
g_form.clearOptions('u_bu_flex');
g_form.addOption('u_bu_flex','','--select Country--');
alert("ibefore for");
for(var i=0;i<buflexCountry.length;i++){
g_form.addOption('u_bu_flex',buflexCountry[i],buflexCountry[i]);
alert("in for");
}
alert("after for");
});
}
and custom table is

and the fields in the Service catalog is

level4 , the field type i have given is Select box, to populate the list of values on that field.
I dont know , where i have made mistake.
method in Script include is executing , but the result is not updating on the Service catalog form.