首页 > 解决方案 > 添加/设置部门名称以联系

问题描述

如何为谷歌联系人中的“部门”字段添加或设置值?“公司”和“职位”没有问题

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-apps-scriptcontacts

解决方案


可以通过具有高级 Google 服务department的 People API进行设置。通过 api 创建联系人时,人员对象可以包括organizations[].department


推荐阅读