Employee Center Menu Item show only to people with direct reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 10:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 01:23 PM
Hi @CCSF-Syd ,
You can create a script include where you can check if user is a manager. Then you can call that script include from the condition field.
Sample Script include code -
var UserManagerUtils = Class.create();
UserManagerUtils.prototype = {
initialize: function() {},
/*
* Check if the logged-in user is a manager based on the 'manager' field in the sys_user table.
* @returns {boolean} - True if the user is a manager, false otherwise.
*/
isManagerByHierarchy: function() {
var userSysId = gs.getUserID();
var gr = new GlideRecord('sys_user');
if (gr.get(userSysId)) {
// Check if the user has direct reports (is a manager)
var directReports = new GlideRecord('sys_user');
directReports.addQuery('manager', userSysId);
directReports.query();
return directReports.hasNext();
}
return false;
},
type: 'UserManagerUtils'
};
Call the script include using below code in the condition field
javascript: new UserManagerUtils().isManagerByHierarchy();
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards,
Satya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 02:10 PM
Got it, that's helpful. Is there no OOB way to check if someone is a Manager? How does Manager Hub do it I wonder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 09:10 PM - edited 02-26-2025 09:11 PM
@CCSF-Syd
Do you use "Manager Hub" on Employee Center, If yes then you can use the gs.hasRole('sn_mh.manager_hub_user') in the condition of Menu Items.
If not then you can create a new role which would help you check if a person is manager or not and assign it to users with direct reports via a scheduled job or manually and still use a gs.hasRole('your_created_role') in menu item condition.
Regards
Sajal