The CreatorCon Call for Content is officially open! Get started here.

Conditional Visibility for Portal Menu Item

anusarma
Kilo Expert

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

1 ACCEPTED SOLUTION

can you try again with below condition in menu items 

 

new getThisUser().getFirstLevelManager()

View solution in original post

6 REPLIES 6

can you try again with below condition in menu items 

 

new getThisUser().getFirstLevelManager()

Yayy it is working fine now with this condition!! Thanks a lot 🙂