in script include how to get the list of users for whom the logged in user is manager
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 07:29 AM
A is manager of B and B is manager of C.
then C should be able to see the B and A list.
and B should only see the A list.
how to get that list...in script include i want...because i am going to apply it as a dynamic filter to achieve it in report
Labels:
- Labels:
-
Scripting and Coding
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 08:01 AM
Hi,
I want it as a hierarchy level of managers....It works for single level....If the flow is n it wont.
Thanx for reply...Can you suggest for n level
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2024 04:21 AM
You can refer the below code snippet:
var UserListScriptInclude = Class.create();
UserListScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// Function to get a list of active users
getActiveUsers: function() {
var userList = [];
var userRecord = new GlideRecord('sys_user');
userRecord.addQuery('manager', gs.getUserID()); // Add conditions based on your requirements
userRecord.query();
while (userRecord.next()) {
var userDetails = {
userId: userRecord.getUniqueValue(),
userName: userRecord.user_name.toString(),
fullName: userRecord.getDisplayValue(),
manager: userRecord.manager.getDisplayValue(),
//manager: userRecord.manager.toString(),
email: userRecord.email.toString(),
// Add more fields as needed
};
userList.push(userDetails);
}
return userList;
},
// For testing purposes - you can call this function to get a list of active users
testGetActiveUsers: function() {
var activeUsers = this.getActiveUsers();
gs.info(JSON.stringify(activeUsers, null, 4));
},
type: 'UserListScriptInclude'
});