- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:25 AM
Hi all,
I have the following code which works as intended, but I don't fully understand why. The function takes in a user, finds their manager and then returns a list of all the users said manager manages. Why/how does the code in red/bold return the users?
getReportee: function(user){
var manager;
var gr = new GlideAggregate('sys_user');
gr.addQuery('sys_id', user);
gr.query();
if (gr.next()){
manager = grgetValu('manager');
}
var grTwo = new GlideRecord('sys_user');
grTwo.addQuery('manager', manager);
grTwo.query();
var user = []
while (grTwo.next()){
users.push(grTwo.getUniqueValue());
}
return users.toString();
}
Thank you!
G
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:30 AM
Hello gunishi,
getUniqueValue returns the primary key of the record, in other words the sys_id of the record. Inside your second loop you are iterating over sys_user table, that's why users arrays will show you a list of user's sys_id.
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:29 AM
Hi Gunishi,
getUniqueValue() : it will not accept any arguments and It is will only return the sys id .
Please find the below link to know more about the this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:30 AM
Hello gunishi,
getUniqueValue returns the primary key of the record, in other words the sys_id of the record. Inside your second loop you are iterating over sys_user table, that's why users arrays will show you a list of user's sys_id.
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:32 AM
Hi Adrian,
Thank you for this, it was exactly the explanation I was looking for!
G
