Class CustomField

ช่องที่กำหนดเอง

เลิกใช้งานแล้ว แต่ให้ใช้บริการขั้นสูงของ People API แทน

ช่องที่กำหนดเองในรายชื่อติดต่อ

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
getLabel()Objectรับป้ายกำกับของช่องนี้
setLabel(label)CustomFieldตั้งค่าป้ายกํากับของช่องนี้
วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
deleteCustomField()voidลบช่องนี้
getValue()Objectรับค่าของช่อง
setLabel(field)CustomFieldตั้งค่าป้ายกํากับของช่องนี้
setValue(value)CustomFieldตั้งค่าของช่องนี้

เอกสารประกอบโดยละเอียด

getLabel()

รับป้ายกำกับของช่องนี้ ซึ่งอาจเป็นฟิลด์ ExtendedField หรือสตริง

// Logs the label for all the address fields associated with contact
// 'John Doe'. This method can be similarly called for any field that has
// a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
for (let i = 0; i < addressFields.length; i++) {
  Logger.log(addressFields[i].getLabel());
}

รีเทิร์น

Object — ป้ายกำกับของช่องนี้

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds

setLabel(label)

ตั้งค่าป้ายกํากับของช่องนี้

// Sets the label to 'Apartment' for the first address field associated
// with contact 'John Doe'. This method can be similarly called for any
// field that has a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');

พารามิเตอร์

ชื่อประเภทคำอธิบาย
labelStringป้ายกำกับใหม่สำหรับช่องนี้

รีเทิร์น

CustomField — ช่องนี้มีประโยชน์สำหรับการต่อเชื่อม

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds

วิธีการที่เลิกใช้งาน

เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่

ลบช่องนี้

const contacts = ContactsApp.getContactsByName('John Doe');
const fields = contacts[0].getCustomFields();
for (let i = 0; i < fields.length; i++) {
  if (fields[i].getLabel() === 'foo') {
    fields[i].deleteCustomField();
  }
}

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds

เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่

รับค่าของช่อง

// Logs the value of all the custom fields for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const fields = contacts[0].getCustomFields();
for (const i in fields) {
  Logger.log(fields[i].getValue());
}

รีเทิร์น

Object — ค่าที่จัดเก็บในช่อง

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds

เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่

ตั้งค่าป้ายกํากับของช่องนี้

// Sets the first custom field associated with contact 'John Doe' to use 'Mail
// application' as a label, with 'Gmail' as the value.
const contacts = ContactsApp.getContactsByName('John Doe');
const field = contacts[0].getCustomFields()[0];
field.setLabel('Mail application');
field.setValue('Gmail');

พารามิเตอร์

ชื่อประเภทคำอธิบาย
fieldExtendedFieldป้ายกำกับมาตรฐานใหม่

รีเทิร์น

CustomField — ช่องนี้มีประโยชน์สำหรับการต่อเชื่อม

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds

เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่

ตั้งค่าของช่องนี้

// Sets the first custom field associated with contact 'John Doe' to use 'Mail
// application' as a label, with 'Gmail' as the value.
const contacts = ContactsApp.getContactsByName('John Doe');
const field = contacts[0].getCustomFields()[0];
field.setLabel('Mail application');
field.setValue('Gmail');

พารามิเตอร์

ชื่อประเภทคำอธิบาย
valueObjectค่าใหม่

รีเทิร์น

CustomField — ช่องนี้มีประโยชน์สำหรับการต่อเชื่อม

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ

  • https://www.google.com/m8/feeds