User Criteria script by Company and Employee Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 10:25 AM
Trying to develop a user criteria for users with OIT company AND u_employee_type = Full Time/Staff
I am impersonating a user who is an OIT AND Employee Type is Vendor and the user can stil see the catalog item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 11:11 AM
Here is a link to the documentation, and here a screenshot to the relevant portion. Best practice is not to use any Session APIs and instead use the provided user_id variable. Hopefully this helps solve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:42 AM
Hi,
There are some restrictions with user criteria. Try the below code,
var userId = gs.user_id();
var user = new GlideRecord('sys_user');
user.get(userId);
if (user.u_employee_type == 'Full Time/Staff') {
answer = true;
} else {
answer = false;
}
Regards,
Dhanraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:50 AM
Here is what I have found to work
1. Remember to log out and back in when testing changes to advanced User Criteria scripts
2. This script worked
answer = checkCondition();
function checkCondition(){
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
if (user.u_employee_type=='Full Time/Staff' && user.company=='OIT')
{
return true;
}
return false;
}
3. And this script worked
answer = checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
var emp_type = user.u_employee_type;
var emp_company = user.company;
if(emp_type == 'Full Time/Staff' && emp_company == 'OIT')
return true;
else
return false;
}