Class CustomField
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Подробная документация
get Label()
Получает метку для этого поля. Это может быть поле, 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
set Label(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'); Параметры
| Имя | Тип | Описание |
|---|
label | String | новая метка для этого поля |
Возвращаться
Custom Field — это поле полезно для цепочки
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-
https://www.google.com/m8/feeds
Устаревшие методы
delete Custom Field()
Устарело. Эта функция устарела и не должна использоваться в новых скриптах.
Удаляет это поле.
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();
}
} Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-
https://www.google.com/m8/feeds
get Value()
Устарело. Эта функция устарела и не должна использоваться в новых скриптах.
Получает значение поля.
// 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 — значение, хранящееся в поле
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-
https://www.google.com/m8/feeds
set Label(field)
Устарело. Эта функция устарела и не должна использоваться в новых скриптах.
Устанавливает метку этого поля.
// 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'); Параметры
Возвращаться
Custom Field — это поле полезно для цепочки
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-
https://www.google.com/m8/feeds
set Value(value)
Устарело. Эта функция устарела и не должна использоваться в новых скриптах.
Устанавливает значение этого поля.
// 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'); Параметры
| Имя | Тип | Описание |
|---|
value | Object | новое значение |
Возвращаться
Custom Field — это поле полезно для цепочки
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-
https://www.google.com/m8/feeds
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-25 UTC.
[null,null,["Последнее обновление: 2025-07-25 UTC."],[],["The `CustomField` in the Contacts API is deprecated in favor of the People API. It allows interacting with a custom field in a contact, using `getLabel()` to retrieve the field's label and `setLabel(label)` to change it. Deprecated methods include `deleteCustomField()` to remove the field, `getValue()` to get the field's value, `setLabel(field)` to set a label, and `setValue(value)` to assign the field's value. These actions require specific authorization scopes.\n"]]