I am calling google admin directory api to get user through email and then storing the organizations return in org.
var user = AdminDirectory.Users.get(bmail);
org = user.organizations;
Output
[ { customType: '',
title: 'PM',
department: 'BIT',
primary: true,
description: 'Permanent' } ]
- How can i get only department in org? I've tried to use get.child(element) to get the department however not successful.
- How can i get only manager's email? I've read the Rest Resource Users but there is no information related to manager's email.
Any reference or help will be much appreciated.
Thank you
CodePudding user response:
You already have the User
object, so if you want to read the department
property you only have to navigate its tree. See the example below:
function myFunction() {
var user = AdminDirectory.Users.get(bmail);
org = user['organizations'][0]['department'];
}
Now to answer your second question you could use the relations
field to keep track of the user's managers. Feel free to drop a comment if you need further clarifications.