how to check the manager

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:27 AM
Hi,
I need to check the current requester is a manager or not. how can i do that in a script. my complete logic would be like follow.
current_user = requesting user
requested_for_user = value of "requested for" field of request
if(manager of requested_for_user == current_user )
{
return 'yes'
}
else
{
return 'no'
}
please let me know a correct way to do this.
Thanks
/Sandaru
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:45 AM
Hi,
If you query on sys_user table in this table we have a Title section or you can use any other flag (custom ) on this table to identify current user is manager or not.
because it may be manager also has manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:48 AM
If i understand you correctly, you either want to know if the current user is a manager OR the current user is a manager of the requested for?
I would do something like this:
To check if the current user is the manager of the requested for user
if(gs.getUserID() == current.requested_for.manager){
return 'yes'
else
return 'no';
To check if the current user is a manager or not:
if(isManager(){
return 'yes';
} else {
return 'no';
}
// Better to define this in a script include
function isManager(){
var usr = new GlideRecord('sys_user');
usr.addQuery('manager', gs.getUserID());
usr.query();
if(usr.query()){
return true;
} else {
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:55 AM
I don't see any function call gs.getUserId()... Can you please send me a reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 01:57 AM
Updated. Its getUserID()