- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 07:23 AM
Hi All,
I am trying to set User Criteria for catalog form like if login user is manager then form will be accessible for him.
trying this code but no success, your help will be appreciated.
Script code -
function checkIfManager(){
gs.log(gs.getUserID());
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
gs.log(gr.hasnext());
}
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 08:21 AM
please try this and let me know if that works well
answer = checkIfManager();
function checkIfManager(){
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
return gr.hasNext();
}
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
08-19-2020 03:39 AM
Hi
I see you tried marking 2 answers as Correct. Only one answer can be Correct. Kindly mark my answer as correct if it works for you. As it includes the user_id variable, which is a good practice, and I was the first to have a working answer.
Thanks in advance!
Kind regards,
Willem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 08:21 AM
please try this and let me know if that works well
answer = checkIfManager();
function checkIfManager(){
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
return gr.hasNext();
}
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
06-21-2024 03:21 AM
I use the same script, but the catalog item in visible to everyone.
Please let me know what can go wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2024 03:23 AM
I am using the same script, still catalog item is visible to everyone
Please let me know what can go wrong.