- 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
07-04-2024 06:57 AM
Thanks! for solution