User Criteria Advance Problem with Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:47 AM
function evaluateControl() {
var user = new GlideRecord('sys_user');
user.query('sys_id=' + user_id);
user.next();
var firstName = user.getValue('first_name').toLowerCase();
var lastName = user.getValue('last_name').toLowerCase();
var roles = new GlideRecord('sys_user_role').query('user=' + user_id);
roles.next();
var isITIL = roles.getValue('role') === 'itil';
var containsManager = firstName.includes('manager') || lastName.includes('manager');
if (isITIL && !containsManager) {
return true;
}
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 10:55 AM - edited 02-27-2024 10:55 AM
Hi @Tomas Linde ,
I see your all 3 posts with similar query, any reason the user has "manager" keywords in the first and last name, are they actual users or some kind of custom service accounts and you are trying to restrict those user on catalog item.
If that is the case, those user should have some other parameter like user type which can be use in User Criteria.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 11:10 AM
Hi @AshishKM
They are default users to whom I want to limit access, which contain the role itil and that keyword in common as parameters to limit access
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 11:21 AM - edited 02-27-2024 11:22 AM
you can disable those default user via active=false instead of applying the user criteria at variable level.
or you can apply the condition on that catalog item variable.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 11:25 AM
Thanks for your response @AshishKM , but I don't want to disable users, I just want to use a correct User Criteria to limit access to the catalog item and know if the one I am applying is correct.