首页 > 解决方案 > 使用对象的值查询 AdminDirectory.Users.get

问题描述

我正在使用 Google Apps 脚本,到目前为止,我可以根据其电子邮件查询用户详细信息:

var result = AdminDirectory.Users.get('some.email@domain.com', {viewType:'domain_public'});
Logger.log(result.externalIds);

在这种情况下,结果仅限于对象“externalIds”并读取:

{customType=Auth ID, type=custom, value=abc123}

现在,有没有办法从电子邮件地址的响应和查询中获取值?就像是:

var result = AdminDirectory.Users.get({customType: 'Auth ID', type: 'custom', value: 'abc123'}, {viewType:'domain_public'});
Logger.log(result.emails);

得到类似的东西:

{address=some.email@domain.com, primary=true}

而且,我可以只从 emails 对象中获取值“地址”吗?

谢谢大家。

编辑:刚刚发现我可以通过以下方式获取特定的字段地址:

Logger.log(result.emails[0].address);

标签: google-apps-script

解决方案


推荐阅读