Reputation: 1
I use this code to logger successfully log : user fullname and user primaryEmail. from property of AdminDirectory.Users.list
But I don't understand how I can get the phone user . The syntax user.phones[].primary doesn't work
function listAllUsers() {
var pageToken, page;
do {
page = AdminDirectory.Users.list({
domain: 'example.com',
orderBy: 'givenName',
maxResults: 100,
pageToken: pageToken
});
var users = page.users;
if (users) {
for (var i = 0; i < users.length; i++) {
var user = users[i];
Logger.log(user.name.fullName, user.primaryEmail,user.phones[].primary);
}
} else {
Logger.log('No users found.');
}
pageToken = page.nextPageToken;
} while (pageToken);
}
The parameters user.phones[] doesnt' work see google reference
Upvotes: 0
Views: 110
Reputation: 1207
You are attempting to access an array (that's what the []
indicates), therefore you must specify an index.
If you want to access the primary
variable of the first value in the phones
array, then you would use:
user.phones[0].primary
Upvotes: 1