- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 06:55 AM
How to restrict catalog form to only particular users?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 08:05 AM
use advanced script in user criteria and then add this user criteria in Available for related list of that item
As recommended practice please use user_id to get logged in user sys_id
var rec = new GlideRecord('sys_user');
rec.get(user_id);
if (rec.u_division == 'OIT Information Technology')
answer = true;
else
answer = false;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 10:20 AM
Hi
You can create user criteria with the below configuration and add to the "Available for" related list if you want only these users to be able to view this catalog item and under "Not Available for" if you want this catalog item to be not available for these users.
Search for user criteria in application filter to create new criteria OR click on the NEW button under Available For related list on catalog item form
User criteria details:
Name: User division is OIT Information Technology
Advance: Checked/true
script:
/**
* Return true is user division is OIT Information Technology
* else return false
*/
var gr = new GlideRecord("sys_user");
gr.get(gs.getUserID().toString());
if (gr && gr.division.toString() == "OIT Information Technology") {
return true; // User Division is "OIT Information Technology"
}
return false;
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Sagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 08:38 AM
Can you write a script that looks for a title of the sys user instead of department? Looking to add to the "Available For" on a catalog item, that is restricted to access only if they are a Manager.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 09:45 AM
Hi @terrieb try below code
/**
* Return true if user title is "Manager"
* else return false
*/
var gr = new GlideRecord('sys_user');
if (gr.get(gs.getUserID())) {
if (gr.title.toString() == "Manager") {
return true; // User title is "Manager"
}
}
return false;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 10:28 AM
I got it to work but will it work if I change the "is" to "contains" instead? We have several "manager" levels, not just "manager" like Senior Manager, etc...
Thanks!