- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:15 AM
Hi All,
We have a requirement to display a header menu item for first level managers/below users only, i.e., it should be visible for users who are not a manager OR who is a first level manager only. By First level manager, what we mean is, suppose user A is manager of user B and user C, neither user B nor user C is a manager of any other user, then user A is a first level manager. In case if any of user B or user C is a manager for any user, then user A is not a first level manager.
I have tried creating a script include for checking this not a manager/first level manager validation, and then calling this script include function in the condition field of the menu item. However, it doesn't seem to work.
Could someone please check if am missing anything?
Menu item condition: getThisUser().getFirstLevelManager()
Script Include:
Name: getThisUser
Script:
var getThisUser = Class.create();
getThisUser.prototype = {
initialize: function() {
},
getFirstLevelManager:function() {
var usr = new GlideRecord('sys_user');
usr.addQuery('manager', gs.getUserID());
usr.query();
if(!usr.next()) //means current user is not a manager for any other user
return true;
else {
var usr1 = new GlideRecord('sys_user');
usr1.addQuery('manager', usr.getValue('sys_id'));
usr1.query();
if(!usr1.next()) //means current user is not a second/upper level manager
return true;
else
return false;
}
},
type: 'getThisUser'
};
-----------------------------------------------------------------------------------------------------------
Thanks in advance,
Anu
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:44 AM
can you try again with below condition in menu items
new getThisUser().getFirstLevelManager()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:20 AM
can you try like this.
javscript: getThisUser().getFirstLevelManager()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:26 AM
Hi Harshvardhan,
Thanks for the quick response, however, it didn't work.
Regards,
Anu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:33 AM
can you run this in background script and see if your script include is working or not.
var ab =new getThisUser().getFirstLevelManager();
gs.log(ab);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2019 02:37 AM
Yes, it is returning true when I ran it in background script.