Skip to content
Advertisement

How get the Employee Title from Admin Directory?

I’m expecting to get the job title of the user via using google app script, but I’m getting the log print as follows

[20-11-17 12:31:35:307 IST] [{title=Manager, department=Marketing, primary=true, customType=}]

The below is my code

function getUserDirectory(){
var user = Session.getActiveUser().getEmail();
var employee = AdminDirectory.Users.get(user).organizations;
Logger.log(employee);
}

What I’m trying to do is get only the title of the employee. I’ve tried adding [1] or [2] or [3] after the .orgainizations object but it doesn’t work.

What would be the right code to get my answer?

Advertisement

Answer

employee is a array of objects and contains only 1 object with index 0. So, use

employee[0].title
6 People found this is helpful
Advertisement