Class CustomField

  • CustomField is deprecated and the People API advanced service should be used instead.

  • It represents a custom field within a Contact and previously allowed for getting, setting, and deleting custom field data.

  • getLabel() and setLabel(label) methods remain available for retrieving and setting the label of a custom field.

  • Several methods, including deleteCustomField(), getValue(), setLabel(field), and setValue(value), are deprecated and should no longer be used.

CustomField

Deprecated. Instead, use the People API advanced service

A custom field in a Contact.

Methods

MethodReturn typeBrief description
getLabel() ObjectGets the label for this field.
setLabel(label) (削除) CustomField (削除ここまで)Sets the label of this field.

Deprecated methods

MethodReturn typeBrief description
(削除) deleteCustomField() (削除ここまで)voidDeletes this field.
(削除) getValue() (削除ここまで)ObjectGets the value of the field.
(削除) setLabel(field) (削除ここまで)(削除) CustomField (削除ここまで)Sets the label of this field.
(削除) setValue(value) (削除ここまで)(削除) CustomField (削除ここまで)Sets the value of this field.

Detailed documentation

getLabel()

Gets the label for this field. This may be a Field, ExtendedField, or a 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.
constcontacts=ContactsApp.getContactsByName('John Doe');
constaddressFields=contacts[0].getAddresses();
for(leti=0;i < addressFields.length;i++){
Logger.log(addressFields[i].getLabel());
}

Return

Object — the label for this field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

setLabel(label)

Sets the label of this field.

// 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.
constcontacts=ContactsApp.getContactsByName('John Doe');
constaddressFields=contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');

Parameters

NameTypeDescription
labelStringthe new label for this field

Return

(削除) CustomField (削除ここまで) — this field, useful for chaining

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

Deprecated methods

(削除) deleteCustomField() (削除ここまで)

Deprecated. This function is deprecated and should not be used in new scripts.

Deletes this field.

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

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

(削除) getValue() (削除ここまで)

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the value of the field.

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

Return

Object — the value stored in the field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

(削除) setLabel(field) (削除ここまで)

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the label of this field.

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

Parameters

NameTypeDescription
field(削除) ExtendedField (削除ここまで)the new standard label

Return

(削除) CustomField (削除ここまで) — this field, useful for chaining

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

(削除) setValue(value) (削除ここまで)

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the value of this field.

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

Parameters

NameTypeDescription
valueObjectthe new value

Return

(削除) CustomField (削除ここまで) — this field, useful for chaining

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年12月02日 UTC.