// 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.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();for(leti=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.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel('Apartment');
// Deletes all the dates that are set for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constdates=contacts[0].getDates();for(leti=0;i < dates.length;i++){dates[i].deleteDateField();}
// Logs the day of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getDay());
// Logs the month of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getMonth());
// Logs the year of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getYear());
// Sets the birthday for contact 'John Doe' to April 1constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];birthday.setDate(ContactsApp.Month.APRIL,1);
// Sets the birthday for contact 'John Doe' to April 1, 1980constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=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 anniversaryconstcontacts=ContactsApp.getContactsByName('John Doe');constfirstDate=contacts[0].getDates()[0];firstDate.setLabel(ContactsApp.Field.ANNIVERSARY);
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-12-22 (世界標準時間)。"],[[["**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."]]],[]]