Sets the label of this field, such as 'Birthday' or 'Anniversary'.
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');
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
Deprecated methods
deleteDateField()
Deprecated. This function is deprecated and should not be used in new scripts.
Deletes this date.
// Deletes all the dates that are set for contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var dates = contacts[0].getDates();
for (var i = 0; i < dates.length; i++) {
dates[i].deleteDateField();
}
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
getDay()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the day of the month for this date.
Note: For standard JavaScript Date objects the getDay() method returns the day of the week instead.
// Logs the day of the birthday for contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getDay());
Return
Integer — the day of the month
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
getMonth()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the month for this date.
// Logs the month of the birthday for contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getMonth());
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
getYear()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the year for this date.
// Logs the year of the birthday for contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getYear());
Return
Integer — the year
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
setDate(month, day)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the date to this day, without a year.
This method only applies to date fields that don't require a year, such as birthdays.
// Sets the birthday for contact 'John Doe' to April 1
var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
birthday.setDate(ContactsApp.Month.APRIL, 1);
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
setDate(month, day, year)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the date to this day.
// Sets the birthday for contact 'John Doe' to April 1, 1980
var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
birthday.setDate(ContactsApp.Month.APRIL, 1, 1980);
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
setLabel(label)
Deprecated. This function is deprecated and should not be used in new scripts.
Sets the label of this field, such as 'Birthday' or 'Anniversary'.
// Retrieves the first date that's set for contact 'John Doe' and re-labels
// it as an anniversary
var contacts = ContactsApp.getContactsByName('John Doe');
var firstDate = contacts[0].getDates()[0];
firstDate.setLabel(ContactsApp.Field.ANNIVERSARY);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-12-16 UTC."],[],[]]