google-apps-script - 添加/设置部门名称以联系
问题描述
如何为谷歌联系人中的“部门”字段添加或设置值?“公司”和“职位”没有问题
var contact = ContactsApp.createContact('John', 'Doe', 'john.doe@example.com');
var company_set = contact.addCompany('Google', 'Product Manager');
// ?????
var department_set = contact.add______________('IT');
UPD:感谢@TheMaster,我设法解决了这个任务。您可以在此处找到不错的 API 示例https://www.any-api.com/googleapis_com/people/docs/people/people_people_createContact 使用此站点上的示例,您可以为 API 构建所需的主体。
var reqBody = {
names: [
{
givenName: givenName,
familyName: familyName
}
],
phoneNumbers: phoneNumbers,
organizations: [
{
title: orgTitle,
department: orgDepartment
}
],
emailAddresses: [
{
value: emailAddres,
type: 'work'
}
],
addresses: [
{
city: city,
streetAddress: streetAddress,
type: 'work'
}
],
memberships: [
{
contactGroupMembership: {
contactGroupId: contactGroupsID,
contactGroupResourceName: "contactGroups/" + contactGroupsID
}
}
]
}
createContact(reqBody);
解决方案
可以通过具有高级 Google 服务department
的 People API进行设置。通过 api 创建联系人时,人员对象可以包括organizations[].department
推荐阅读
- haskell - 在 Haskell 中将数字读取为文本、tshow 和显示
- node.js - 错误:连接处于关闭状态时无法添加新命令
- php - 在 ACF 转发器字段的“While”之后显示值
- ios - 如何创建一个精度为 0.1 秒的计时器?
- r - R 堆积条形图
- ssl - 如何修复“javax.net.ssl.SSLHandshakeException:链验证失败”
- symfony - Symfony 4重定向循环以登录表单多个角色
- vb.net - 忽略空白文本框
- mysql - 如何准确选择用户名和密码注意大小写字母 - mysql
- python - After using @ray decorator can't add data to dictionary