User Criteria for a Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 11:26 AM
Hello All,
I want my catalog item should be available only to a particular group and for users who are managers. I am trying to use my Available for and Not available for my catalog item but it was not working as expected. Can anyone pls guide me on this user criteria inorder to restrict my catalog.
My catalog item should be available only to users who are manager and for one particular group(EG:hardware).
Thanks in advance...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 01:06 PM
Hello @Ashwin Ganesh ,
Please give a try to the script below and see how it works for you and add your group in the groups field.
checkCondition();
answer = ifScript();
// Your comments go here (metadata)
function ifScript() {
// Get the current logged-in user
var currentUserID = gs.getUserID();
// Query the sys_user table for records where the current user is listed as a manager
var userGr = new GlideRecord('sys_user');
userGr.addQuery('manager', currentUserID);
userGr.query();
// Check if any records were found
if (userGr.hasNext()) {
return 'true'; // User is a manager, grant access
} else {
return 'false'; // User is not a manager, restrict access
}
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket