Class PhoneField

電話番号フィールド

非推奨。代わりに、People API アドバンスト サービスを使用してください。

連絡先の電話番号フィールド。

メソッド

メソッド戻り値の型概要
getLabel()Objectこのフィールドのラベルを取得します。
isPrimary()Booleanこれが主なフィールド値かどうかを取得します。
setAsPrimary()PhoneFieldこのフィールドをプライマリに設定します。
setLabel(field)PhoneFieldこのフィールドのラベルを設定します。
setLabel(label)PhoneFieldこのフィールドのラベルを設定します。
メソッド戻り値の型概要
deletePhoneField()voidこの電話番号フィールドを削除します。
getPhoneNumber()Stringこのフィールドの電話番号を取得します。
setPhoneNumber(number)PhoneFieldこのフィールドの電話番号を設定します。

詳細なドキュメント

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.
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

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 - プライマリかどうか

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

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

setAsPrimary()

このフィールドをプライマリに設定します。

// 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

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

  • 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

承認

このメソッドを使用するスクリプトには、次のスコープの 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このフィールドの新しいラベル

戻る

PhoneField - チェーンに便利なフィールド

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

  • 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();

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

  • 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 - 数値を文字列として指定

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

  • 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 - チェーンに便利なフィールド

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。

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