Class PhoneField

電話欄位

已淘汰。請改用 People API 進階服務

聯絡人中的電話號碼欄位。

方法

方法傳回類型簡短說明
getLabel()Object取得這個欄位的標籤。
isPrimary()Boolean取得是否為主要欄位值。
setAsPrimary()PhoneField將這個欄位設為 primary。
setLabel(field)PhoneField設定這個欄位的標籤。
setLabel(label)PhoneField設定這個欄位的標籤。
方法傳回類型簡短說明
deletePhoneField()void刪除這個電話號碼欄位。
getPhoneNumber()String取得這個欄位的電話號碼。
setPhoneNumber(number)PhoneField設定這個欄位的電話號碼。

內容詳盡的說明文件

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:這個欄位的標籤

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

isPrimary()

取得是否為主要欄位值。

// Logs whether or not the first address field associated with contact
// 'John Doe' is labeled as primary. This method can be similarly called
// for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
Logger.log(addressFields[0].isPrimary());

回攻員

Boolean:是否為主要

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

setAsPrimary()

將這個欄位設為 primary。

// Sets the first address field associated with contact 'John Doe'
// as primary. This method can be similarly called for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setAsPrimary();

回攻員

PhoneField:用於鏈結的 FieldValue

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

setLabel(field)

設定這個欄位的標籤。

// Sets the label to 'Work' 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(ContactsApp.Field.WORK_ADDRESS);

參數

名稱類型說明
fieldField新的標準標籤

回攻員

PhoneField:用於鏈結的 FieldValue

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

  • 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這個欄位的新標籤

回攻員

PhoneField:這個欄位可用於鏈結

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

已淘汰的方法

已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

刪除這個電話號碼欄位。

// Retrieves and deletes the work phone number field for contact 'John
// Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
phoneFields[0].deletePhoneField();

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

取得這個欄位的電話號碼。

// Logs the work phone number for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
Logger.log(phoneFields[0].getPhoneNumber());

回攻員

String:以字串形式表示的數字

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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

已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

設定這個欄位的電話號碼。

// Sets the work phone number for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
phoneFields[0].setPhoneNumber('212-555-1234');

參數

名稱類型說明
numberString新號碼

回攻員

PhoneField:這個欄位可用於鏈結

授權

使用這個方法的腳本需要具備下列一或多個範圍的授權:

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