Class CustomField
Stay organized with collections
Save and categorize content based on your preferences.
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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
for (var i = 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');
Parameters
Name | Type | Description |
label | String | the 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var fields = contacts[0].getCustomFields();
for (var i = 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'
var contacts = ContactsApp.getContactsByName('John Doe');
var fields = contacts[0].getCustomFields();
for (var i in fields) {
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.
var contacts = ContactsApp.getContactsByName('John Doe');
var field = contacts[0].getCustomFields()[0];
field.setLabel('Mail application');
field.setValue('Gmail');
Parameters
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.
var contacts = ContactsApp.getContactsByName('John Doe');
var field = contacts[0].getCustomFields()[0];
field.setLabel('Mail application');
field.setValue('Gmail');
Parameters
Name | Type | Description |
value | Object | the 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 2022-12-16 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{
"lastModified": "Last updated 2022-12-16 UTC.",
"confidential": False
}