Class CustomField

カスタムフィールド

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

連絡先のカスタム フィールド。

メソッド

メソッド戻り値の型概要
getLabel()Objectこのフィールドのラベルを取得します。
setLabel(label)CustomFieldこのフィールドのラベルを設定します。
メソッド戻り値の型概要
deleteCustomField()voidこのフィールドを削除します。
getValue()Objectフィールドの値を取得します。
setLabel(field)CustomFieldこのフィールドのラベルを設定します。
setValue(value)CustomFieldこのフィールドの値を設定します。

詳細なドキュメント

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

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