set the user criteria of a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 05:52 AM
I have written the above script in 'Available for" related list in a catalog item, so that catalog will be visible only gor internal users. But its not working as expected. Kindly suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 05:59 AM
Hi,
Try this
var user = GlideUser.getUserByID(user_id);
if (user.u_type_of_user == 'Internal') {
answer = true;
} else {
answer = false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 06:01 AM - edited ‎06-19-2024 06:03 AM
Couple things I wanted to note and verify. Is your Value of "Internal" correct? Are you sure that is the exact value? You should verify also that what you are getting as a value to compare against In addition, if you are having problems testing it, this may be your issue. You should not be using gs.getUser() in User Criteria as it can cause issues in testing. Here is a link to the Docs page and a screenshot of the relevant info to explain why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 06:04 AM - edited ‎06-19-2024 07:22 AM
Hi @NiloferS ,
You can use this script
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', user_id);
gr.addQuery('u_type_of_user', 'Internal');
gr.query();
return gr.next();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2024 06:50 AM
You have not considered the logged in user.
The query is not right.