- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2018 03:37 AM
Hi,
I need to write an script include for an catalog item field: (field is an Reference field to user table) where in if User logged is an manager, then only the manager employee's should be visible in the list of that reference field.
Please help me in this code
Thanks for the help!!!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2018 04:37 AM
hi maneesh,
Try with the following changes in your code:
function checkIfManager(){
var employees=[];
var currentUser = gs.getUser();
if(currentUser.isMemberOf('<Your group name>')){
var gr= new GlideRecord('sys_user');
gr.addActiveQuery(); // Filter to return active records.
gr.query();
while(gr.next()){
employees.push( gr.sys_id.toString());
}
}
else{
var gr= new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
while(gr.next()){
employees.push(gr.sys_id.toString());
}
}
return "sys_idIN"+employees;
}
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2018 04:37 AM
hi maneesh,
Try with the following changes in your code:
function checkIfManager(){
var employees=[];
var currentUser = gs.getUser();
if(currentUser.isMemberOf('<Your group name>')){
var gr= new GlideRecord('sys_user');
gr.addActiveQuery(); // Filter to return active records.
gr.query();
while(gr.next()){
employees.push( gr.sys_id.toString());
}
}
else{
var gr= new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
while(gr.next()){
employees.push(gr.sys_id.toString());
}
}
return "sys_idIN"+employees;
}
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2018 09:12 PM
Thanks a lot Karishma for your valuable help. This worked like charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 08:35 AM
Hello,
I have the same issue where catalog item field: (field is an Reference field to user table) where in if User logged is an manager, then only the manager employee's should be visible in the list of that reference field.
Above script is not working somehow. May be some update needed.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2024 11:17 PM - edited 07-04-2024 06:40 AM
I tried but not working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 06:52 AM