Class DateField

  • Deprecated: The DateField class is deprecated; use the People API advanced service instead.

  • Represents a date field within a Contact, specifically for the Contacts service.

  • Offers limited functionality with getLabel() and setLabel() methods for managing date field labels.

  • Previously provided methods for manipulating date values are now deprecated, including getDay(), getMonth(), getYear(), and setDate().

  • For general date manipulation in Apps Script, use JavaScript's standard Date object.

DateField

Deprecated. Instead, use the People API advanced service

A date field in a Contact.

This class is only used by the Contacts service, and dates used elsewhere in App Script use JavaScript's standard Date object.

Methods

MethodReturn typeBrief description
getLabel()ObjectGets the label for this field.
setLabel(label)DateFieldSets the label 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.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
for (let 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.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');

Parameters

NameTypeDescription
labelStringthe new label for this field

Return

DateField — 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