如何在App-Script中添加多个用户属性?

发布于 2025-01-26 13:48:50 字数 813 浏览 2 评论 0原文

我正在自动化组织中的入职过程,并具有与App-Script相连的Google表单。 但我想添加更多属性,例如经理的名称,部门,电话号码

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": manager,
    "type": manager,
  }],
  "password": password,
};

console.log(password);

try {
  user = AdminDirectory.Users.insert(user);
  console.log('User %s created with ID %s.', user.primaryEmail, user.id);
} catch (err) {
  console.log('Failed with error %s', err.message);
}

用户正在Google Admin中创建, 以下错误:(

Failed with error API call to directory.users.insert failed with error: Invalid value for: TEST is not a valid value

对于上下文,我以表格为经理的价值进行了测试)

请让我知道我在做错了什么,以便我可以解决此问题。 谢谢!

I am automating the onboarding process in our organization and have a google form connected with app-script. The user is getting created in google admin but I would like to add more attributes such as Manager's name, Department, phone number etc.

Here is the API method:

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": manager,
    "type": manager,
  }],
  "password": password,
};

console.log(password);

try {
  user = AdminDirectory.Users.insert(user);
  console.log('User %s created with ID %s.', user.primaryEmail, user.id);
} catch (err) {
  console.log('Failed with error %s', err.message);
}

But as of now, there is something wrong with the manager code because I get the following error:

Failed with error API call to directory.users.insert failed with error: Invalid value for: TEST is not a valid value

(For context, I had put in TEST as the manager's value in the form)

Please let me know what I am doing wrong so I can fix this.
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗化ㄋ丶相逢 2025-02-02 13:48:51

经过文档在这里

“ ...关系:用户与其他用户的关系列表...”

有关关系值类型:

  1. 类型接受值:

    admin_assistant,助理,兄弟,孩子,定制,foree toury_partner,dotted_line_manager,exec_assistant,父亲,朋友,朋友,经理,母亲,父母,父母,伴侣,伴侣,reflerred_by,亲戚,姐妹,配偶

自定义:让您添加自定义值。

  1. 值是指用户与用户相关的人。它可以是下面看到的名称或电子邮件地址。

在入职场景中,可以实现此功能来为此用户指定经理的电子邮件地址:

let email = '[email protected]'
let givenName = 'X'
let familyName = 'testOnly'
let password = 'passowerd#$"#$22'


let type = 'manager'
let value = '[email protected]'

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": value,
    "type": type,
  }],
  "password": password,
};

=“ https://i.sstatic.net/qqffrd.png”

“

After going through the documentation here it states:

"... relations: A list of the user's relationships to other users..."

As for relation value types:

  1. type accepts values:

    admin_assistant, assistant, brother, child, custom, domestic_partner, dotted_line_manager, exec_assistant, father, friend, manager, mother, parent, partner, referred_by, relative, sister, spouse

Custom: Let's you add custom values.

  1. values refer to the person the user is related to. It can be a name or an email address as seen below.

In the onboarding scenario, this can be implemented to specify the manager's email address for this user:

let email = '[email protected]'
let givenName = 'X'
let familyName = 'testOnly'
let password = 'passowerd#
quot;#$22'


let type = 'manager'
let value = '[email protected]'

var user = {
  "primaryEmail": email,
  "name": {
    "givenName": givenName,
    "familyName": familyName
  },
  "relations": [{
    "value": value,
    "type": type,
  }],
  "password": password,
};

And this succeeds:

enter image description here

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文