Get Reference field values based on Choice field in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2022 08:25 AM - edited ‎11-13-2022 08:41 AM
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'
};
Fields in groups table:
in catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 07:42 AM
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.