Class AddressField

AddressField

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

聯絡人的地址欄位。

方法

方法傳回類型簡短說明
getAddress()String取得這個欄位的地址。
getLabel()Object取得這個欄位的標籤。
isPrimary()Boolean取得這是否為主要欄位值。
setAddress(address)AddressField設定這個欄位的地址。
setAsPrimary()AddressField將這個欄位設為主要欄位。
setLabel(field)AddressField設定這個欄位的標籤。
setLabel(label)AddressField設定這個欄位的標籤。

內容詳盡的說明文件

getAddress()

取得這個欄位的地址。

// Logs the address for the 'Home Address' field for contact 'John Doe'.
// Can be used similarly for other fields that contain addresses.
var contacts = ContactsApp.getContactsByName('John Doe');
var homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);
Logger.log(homeAddress[0].getAddress());

回攻員

String:以字串表示的地址

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

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

getLabel()

取得這個欄位的標籤。可以是 Field、ExtendedField 或 String。

// 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
for (var 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
Logger.log(addressFields[0].isPrimary());

回攻員

Boolean:是否主要

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

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

setAddress(address)

設定這個欄位的地址。

// Sets the address for the 'Home Address' field for contact 'John Doe'.
// Can be used similarly for other fields that contain addresses.
var contacts = ContactsApp.getContactsByName('John Doe');
var homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);
homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');

參數

名稱類型說明
addressString新地址

回攻員

AddressField:這個欄位,適用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

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

setAsPrimary()

將這個欄位設為主要欄位。

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

回攻員

AddressField — 用於鏈結的 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);

參數

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

回攻員

AddressField — 用於鏈結的 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');

參數

名稱類型說明
labelString為這個欄位輸入新標籤

回攻員

AddressField:這個欄位,適用於鏈結

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

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

已淘汰的方法