Create user criteria for Group managers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 10:24 PM
Hello,
We need to make the catalog item visible to the users who are group managers in sys_user_group table.
Any thoughts?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 10:36 PM
Hi @Community Alums ,
Create Script include getManger
script
var getManger = Class.create();
getManger.prototype = {
initialize: function() {
},
canEditOwnershipGroup : function(){
var sys_usrgroup = new GlideRecord("sys_user_group");
sys_usrgroup.addQuery("manager",gs.getUser().getID());
sys_usrgroup.query();
if(sys_usrgroup.hasNext()){
return true;
}else{
return false;
}
},
type: 'getManger'
};
User criteria
then add to catalog item
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 10:58 PM
Hi @Community Alums,
You can try the following steps in the User Criteria script:
- Click the NEW button in the Available for related list.
- Check the Advanced checkbox.
- In the script section, use the code below:
var groupRef = new GlideRecord('sys_user_group');
if (groupRef.get('manager', user_id)) {
answer = true;
} else {
answer = false;
}
Please mark my solution as Helpful and Accepted, if it works for you in any way!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 11:02 PM - edited 10-23-2024 11:04 PM
Hi @Community Alums ,
You can create a new User Criteria that grants access exclusively to the group manager.
Please use the following code in the user criteria script to ensure that only the group manager can access the item.
var grpManager = new GlideRecord('sys_user_group');
grpManager.addActiveQuery();
grpManager.addQuery('manager', gs.getUserID());
grpManager.query();
if (grpManager.hasNext()) {
answer = true;
} else {
answer = false;
}
After that, you can add this User Criteria to the "Available For" related list in your catalog item.
[Note- If it still doesn't work, try clearing the cache using cache.do in the filter navigator, as it may take some time to apply changes.]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 11:27 PM
Hello,
I tried above answers . But they are not working for me.
I have following record in "sys_user_group" table. But Catalog item is not visible to "Jacinto Gawron" after impersonation.