Display users according to condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 03:05 AM - edited 11-12-2023 03:06 AM
Hi All,
Good Day!
There is a variable in the variable set name "var", it is showing on 3 catalog items. Its type is Reference and link with the user table, I want to show the group member of this group "ITOM" to first catalog 1. but for all others, it should show all users while for the first catalog, it should show ITOM members.
I am using the Reference Qualifier:
javascript:((current.type == "cat1") ? "active=true^sys_idIN"+getIDs("0a52d3dcd7011200f2d224837e6103f2") : "active=true^assigned_toISNOTEMPTY=true"); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}"
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2023 03:17 AM
The best practice as per your scenario is to create a separate variable for the third catalog item where you want to show the members from the ITOM group only, still you want to show the same variable, you can do something like this:
javascript: getMembers(current.cat_item);
function getMembers(catalog){
if(catalog == "sys_id_of_1_catalog_item"){ // where you need ITOM group
var grMem = new GlideRecord("sys_user_grmember");
grMem.addQuery("group","SYS_ID_OF_ITOM_group");
grMem.query();
var str = "";
while(grMem.next()){
str = str + grMem.user + ",";
}
return "sys_idIN" + str;
}
return; // if other catalogs, it will directly come here
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.