Get Reference field values based on Choice field in catalog item

Vamshi Krishna2
Tera Contributor

Hi I have 2 variables LOB(Reference) and Domain(Select box) I'm trying to get the lob values based on the domain selected from groups table. but below script is showing blank output in the Reference variable.

Script Include:

Check: function(){
var Select_domain = current.variables.domain;
var lblist = new GlideRecord('sys_user_group');
lblist.addQuery('u_domain',Select_domain);
lblist.query();
var finalList = [];
while(lblist.next()){
finalList.push(lblist.getValue('sys_id'));
}
return 'sys_idIN' + finalList.join(',');

},
type: 'Populate_Groups'
};

VamshiKrishna2_0-1668356397671.png

Fields in groups table:

 

VamshiKrishna2_2-1668356585280.png

in catalog form

VamshiKrishna2_3-1668356646384.png

VamshiKrishna2_5-1668356722506.png

 

 

 

5 REPLIES 5

Hello,

 

Can you use the below script include once:-

 



var PopulateGroupName = Class.create();
PopulateGroupName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroupNames: function() {
//var names = '';
var arr = [];
var dom = this.getParameter('sysparm_lob');
if (dom == "lc_aero") {
dom = "LC Aero";
}
else if (dom == 'yd_com'){
dom = "YD COM";
}
else if (dom == 'dc_com'){
dom = "DC COM";
}
else if (dom == 'hbsi_iad'){
dom = "HBSI IAD";
}
var gr = new GlideRecord('sys_user_group');
gr.addQuery('u_domain',dom);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('u_lob'));
}
return 'u_lobIN' + arr.join(',');
},
type: 'PopulateGroupName'
});

 

If the above does not work please use some alerts in the client script and logs in script include to check till what point the script is coming and failing

 

Please mark my answer as correct based on Impact.