Catalog item variable choices should be visible for perticuler group !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2024 02:42 AM
Hi ,
I have a requirement to create a catalog item with the following variables.
in catalog item Monitor selection variable have 3 choices,
The choice (34" Monitor) should be visible mentioned group , I need your help for this.
can please help me to achieve this
Current monitor to be replaced: [Open text]
Monitor selection:
- 24" Monitor
- 27" Monitor
- 34" Monitor (Visible to only EPD and Finance only)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2024 04:34 AM
One solution is to use an onLoad client script that performs a GlideAjax call to check whether the current user (assuming you want this for the current user, and not the requested for) is a member of the mentioned group. If they're not, then the g_form.removeOption function can be used to omit the 34" monitor option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2024 06:44 AM
Hi @Barathk ,
Could you please clarify what do you mean by "The choice (34" Monitor) should be visible mentioned group" do you mean there is a field which store group name or you want to check logged in user or randomly for some group you want to hide this option ?
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2024 09:09 AM
Hi @swathisarang98
EPD and Finance is group name for this group members only have to select the choice field other group member its should be hide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-15-2024 01:19 PM - edited ā05-15-2024 01:22 PM
@Barathk ,
Create a onload Client script and call a script include in the script include check the logged in user is part of epd or finance group and return the binary values, based on these values show or hide the choices,
Onload catalog client script:
function onLoad() {
var ga = new GlideAjax('getMyGroupIn');
ga.addParam('sysparm_name', 'getGroupDetails');
ga.getXML(getResponse);
}
function getResponse(response) {
var ans = response.responseXML.documentElement.getAttribute("answer");
//alert(ans);
if (ans == true || ans == 'true') {
g_form.removeOption('monitor_selection', 34); // change the backend name accordingly
}
}
Client callable Script include:
var getMyGroupIn = Class.create();
getMyGroupIn.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroupDetails: function(){
var epd = gs.getUser().isMemberOf('Database');//checking if logged in user is member of database group for testing
var finance =gs.getUser().isMemberOf('Hardware');//checking if logged in user is member of Finance group for testing
// gs.info('epd: ' +epd);
// gs.info('finance: ' +finance);
if (epd == true || finance == true){
return false;
}
else{
return true;
}
},
type: 'getMyGroupIn'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang