- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2018 02:08 PM
Hello - I am working on a User Criteria requirement for a Catalog Item that I am adding. We have a custom field on the sys_user table called: u_job_code. I only want users with a specific job code to see this catalog item. This u_job_code field is not a reference field.
I was wondering how I would be able to script that in the Advanced script box of the User Criteria record for this. I would like it to filter for users where the u_jobe_code = 1000
Thanks!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2018 10:04 AM
Sorry ...Correction in code. Didnt add a space after function in previous script
checkCondition();
function checkCondition(){
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
if (user.u_job_code==1000)
{
return true;
}
return false;
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2021 10:48 AM
Hi Winston,
can you provide your script and how you used "user_id"?
thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2021 11:07 AM
Hello,
This should be it:
checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.get(user_id);
if(user.u_custom_field == true) {
return true;
}
return false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2021 03:04 PM
Per the documentation:
- Do not use gs.getUser() or other session APIs since they cause conflict when used in diagnostic tools. Use the pre-defined user_id variable available in the script to get the user id of the user being used to evaluate the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2018 06:25 AM
That worked! Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 07:16 AM
Hello - I am working on a User Criteria requirement.
Can anyone help me with the script part.
Requirement is :
Catalog items are classified based on IT and Non-IT Services.
A new User Criteria record for IT Service-related catalog items will be created with below condition –
User’s Department= ”IT” OR
Parent Department of User Department’s = ”IT” OR
User’s Manager Department= ”IT”