0

I'm trying to use the below function

function getuser() {
 var userEmail = 'xxx@xxx.com';
  var user = AdminDirectory.Users.get(userEmail);
  Logger.log(user.relations);
}

I can get

[{type=manager, value=yyy@xxx.com}]

If I only need output 'yyy@xxx.com'

Any ideas? Kind regards

Key Zhou
  • 3
  • 2

1 Answers1

0
  • relations is an array that can contain more than one element
  • Each element contains two key-value pairs
  • To access the value related to a key, you need to address a specific array element or loop through all array elements

Sample

function getuser() {
  var userEmail = 'xxx@xxx.com';
  var user = AdminDirectory.Users.get(userEmail);
  var relations = user.relations;
  for (var i =0; i < relations.length; i++){
    Logger.log(user.relations[i].value);
  }
}
ziganotschka
  • 25,866
  • 2
  • 16
  • 33