이 필드의 라벨을 가져옵니다. 필드, 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.
var contacts = ContactsApp.getContactsByName('John Doe');
var addressFields = contacts[0].getAddresses();
for (var i = 0; i < addressFields.length; i++) {
Logger.log(addressFields[i].getLabel());
}
// 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');
// 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();
}
참고: 표준 자바스크립트 날짜 객체의 경우 getDay() 메서드가 대신 요일을 반환합니다.
// 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());
// 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());
// 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());
// 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);
// 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);
// 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);