A Contact contains the name, address, and various contact details of a contact.
Methods
Method | Return type | Brief description |
---|---|---|
addAddress(label, address) | AddressField | Adds an address to the contact with either a standard or custom label. |
addCompany(company, title) | CompanyField | Adds a company to the contact. |
addCustomField(label, content) | CustomField | Adds a custom field to the contact with either an extended or custom label. |
addDate(label, month, day, year) | DateField | Adds a date to the contact with either an standard or custom label. |
addEmail(label, address) | EmailField | Add an email address with a standard label (home, work, etc.) or a custom label |
addIM(label, address) | IMField | Adds an IM address to the contact with either a standard or custom label. |
addPhone(label, number) | PhoneField | Adds a phone number to the contact with either a standard or custom label. |
addToGroup(group) | Contact | Adds this contact to the given contact group. |
addUrl(label, url) | UrlField | Adds a URL to the contact with either a standard or custom label. |
deleteContact() | void | Deletes this contact. |
getAddresses() | AddressField[] | Gets all the addresses for this contact. |
getAddresses(label) | AddressField[] | Gets all the addresses for this contact matching a particular field. |
getCompanies() | CompanyField[] | Gets all the companies for this contact. |
getContactGroups() | ContactGroup[] | Gets all the contact groups that contain this contact. |
getCustomFields() | CustomField[] | Gets all the custom fields for this contact. |
getCustomFields(label) | CustomField[] | Gets all the custom fields for this contact matching a particular field. |
getDates() | DateField[] | Gets all the dates for this contact. |
getDates(label) | DateField[] | Gets all the dates for this contact matching a particular field. |
getEmails() | EmailField[] | Gets the email addresses of this contact. |
getEmails(label) | EmailField[] | Gets the email addresses for this contact matching a particular field. |
getFamilyName() | String | Gets the family name (last name) of the contact as a string. |
getFullName() | String | Gets the full name (given name and last name) of the contact as a string. |
getGivenName() | String | Gets the given name (first name) of the contact as a string. |
getIMs() | IMField[] | Gets all the IM addresses for this contact. |
getIMs(label) | IMField[] | Gets all the IM addresses for this contact matching a particular field. |
getId() | String | Returns the unique id of this contact. |
getInitials() | String | Gets the contact's initials. |
getLastUpdated() | Date | Gets the date this contact was last updated. |
getMaidenName() | String | Gets the maiden name of the contact as a string. |
getMiddleName() | String | Gets the middle name of the contact as a string. |
getNickname() | String | Gets the nickname of the contact as a string. |
getNotes() | String | Gets the notes associated with this contact, or an empty string if there are no notes. |
getPhones() | PhoneField[] | Gets all the phone numbers for this contact. |
getPhones(label) | PhoneField[] | Gets all the phone numbers for this contact matching a particular field. |
getPrefix() | String | Gets the prefix to the contact's name. |
getPrimaryEmail() | String | Gets the primary email address of the contact as a string. |
getShortName() | String | Gets the short name of the contact as a string. |
getSuffix() | String | Gets the suffix to the contact's name. |
getUrls() | UrlField[] | Gets all the URLs for this contact. |
getUrls(label) | UrlField[] | Gets all the URLs for this contact matching a particular field. |
removeFromGroup(group) | Contact | Removes this contact from the given contact group. |
setFamilyName(familyName) | Contact | Sets the family name (last name) of the contact. |
setFullName(fullName) | Contact | Sets the full name (given name and last name) of the contact. |
setGivenName(givenName) | Contact | Sets the given name (first name) of the contact. |
setInitials(initials) | Contact | Sets the contact's initials. |
setMaidenName(maidenName) | Contact | Sets the maiden name of the contact. |
setMiddleName(middleName) | Contact | Sets the middle name of the contact. |
setNickname(nickname) | Contact | Sets the nickname of the contact. |
setNotes(notes) | Contact | Sets the notes associated with this contact. |
setPrefix(prefix) | Contact | Sets the prefix to the contact's name. |
setShortName(shortName) | Contact | Sets the short name of the contact. |
setSuffix(suffix) | Contact | Sets the suffix to the contact's name. |
Detailed documentation
addAddress(label, address)
Adds an address to the contact with either a standard or custom label.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and adds the address // "123 Main St, Some City, NY 10011" with the the ContactsApp.Field.WORK_ADDRESS label. var contacts = ContactsApp.getContactsByName('John Doe'); var address = contacts[0].addAddress(ContactsApp.Field.WORK_ADDRESS, '123 Main St, Some City, NY 10011');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new address, either from ContactsApp.Field or a custom string |
address | String | the new address |
Return
AddressField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addCompany(company, title)
Adds a company to the contact.
// The code below retrieves a contact named "John Doe" and adds the company "Google" and the // job title "Product Manager". var contacts = ContactsApp.getContactsByName('John Doe'); var url = contacts[0].addCompany('Google', 'Product Manager');
Parameters
Name | Type | Description |
---|---|---|
company | String | the name of the company to add to this contact |
title | String | the job title associated with this contact for this company |
Return
CompanyField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addCustomField(label, content)
Adds a custom field to the contact with either an extended or custom label.
The label can be either from ContactsApp.ExtendedField or a custom label string.
// The code below retrieves a contact named "John Doe" and adds the custom field // ContactsApp.ExtendedField.HOBBY with the value "hiking". // Note that ContactsApp.ExtendedField.HOBBY is not the same as a custom field named 'HOBBY'. var contacts = ContactsApp.getContactsByName('John Doe'); contacts[0].addCustomField(ContactsApp.ExtendedField.HOBBY, 'hiking');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new address, either from ContactsApp.ExtendedField or a custom string |
content | Object | the value to store in the custom field |
Return
CustomField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addDate(label, month, day, year)
Adds a date to the contact with either an standard or custom label.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and adds a // ContactsApp.ExtendedField.BIRTHDAY with the value "April 19, 1950". var contacts = ContactsApp.getContactsByName('John Doe'); var birthday = contacts[0].addDate(ContactsApp.Field.BIRTHDAY, ContactsApp.Month.APRIL, 19, 1950);
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new date, either from ContactsApp.Field or a custom string |
month | Month | the month, from ContactApps.Month |
day | Integer | the day |
year | Integer | the year |
Return
DateField
— the newly created date
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addEmail(label, address)
Add an email address with a standard label (home, work, etc.) or a custom label
// The code below retrieves a contact named "John Doe" and adds the email address // "j.doe@example.com" to the ContactsApp.Field.HOME_EMAIL label. var contacts = ContactsApp.getContactsByName('John Doe'); var emailField = contacts[0].addEmail(ContactsApp.Field.HOME_EMAIL, 'j.doe@example.com');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new email, either from ContactsApp.Field or a custom string |
address | String | the new email address |
Return
EmailField
— the newly added field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
addIM(label, address)
Adds an IM address to the contact with either a standard or custom label.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and adds the IM address "ChatWithJohn" // with the the ContactsApp.Field.AIM label. var contacts = ContactsApp.getContactsByName('John Doe'); var email = contacts[0].addIM(ContactsApp.Field.AIM, 'ChatWithJohn');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new IM address, either from ContactsApp.Field or a custom string |
address | String | the new IM address |
Return
IMField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addPhone(label, number)
Adds a phone number to the contact with either a standard or custom label.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and adds the phone number // "212-555-1234" with the the ContactsApp.Field.WORK_PHONE label. var contacts = ContactsApp.getContactsByName('John Doe'); var phone = contacts[0].addPhone(ContactsApp.Field.WORK_PHONE, '212-555-1234');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new phone number, either from ContactsApp.Field or a custom string |
number | String | the new phone number |
Return
PhoneField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addToGroup(group)
Adds this contact to the given contact group.
// The code below creates a new contact and then adds it to the contact group named // "Work Friends" var contact = ContactsApp.createContact('John', 'Doe', 'john.doe@example.com'); var group = ContactsApp.getContactGroup('Work Friends'); contact = contact.addToGroup(group);
Parameters
Name | Type | Description |
---|---|---|
group | ContactGroup | the contact group to add this contact to |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
addUrl(label, url)
Adds a URL to the contact with either a standard or custom label.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and adds the URL // "http://www.example.com" with the the ContactsApp.Field.WORK_WEBSITE label. var contacts = ContactsApp.getContactsByName('John Doe'); var url = contacts[0].addUrl(ContactsApp.Field.WORK_WEBSITE, 'http://www.example.com');
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label of the new address, either from ContactsApp.Field or a custom string |
url | String | the new URL |
Return
UrlField
— the newly created field
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
deleteContact()
Deletes this contact.
var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].deleteContact(); }
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getAddresses()
Gets all the addresses for this contact.
// The code below logs the addresses of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getAddresses()); }
Return
AddressField[]
— a list of addresses
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getAddresses(label)
Gets all the addresses for this contact matching a particular field.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the addresses // associated with that contact that are in the ContactsApp.Field.WORK_ADDRESS label. var contacts = ContactsApp.getContactsByName('John Doe'); var addresses = contacts[0].getAddresses(ContactsApp.Field.WORK_ADDRESS); for (var i in addresses) { Logger.log(addresses[i].getAddress()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
AddressField[]
— a list of addresses
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getCompanies()
Gets all the companies for this contact.
// The code below logs the company names of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { var companies = contacts[i].getCompanies(); for (var j in companies) { Logger.log(companies[j].getCompanyName()); } }
Return
CompanyField[]
— a list of companies
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactGroups()
Gets all the contact groups that contain this contact.
// The code below gets a contact named "John Doe" and retrieves all the contact groups that // the contact belongs to var contacts = ContactsApp.getContactsByName('John Doe'); var groups = contacts[0].getContactGroups();
Return
ContactGroup[]
— the groups containing this contact
See also
getCustomFields()
Gets all the custom fields for this contact.
// The code below retrieves a contact named "John Doe" and logs the custom fields // associated with that contact var contacts = ContactsApp.getContactsByName('John Doe'); var fields = contacts[0].getCustomFields(); for (var i in fields) { Logger.log(fields[i].getValue()); }
Return
CustomField[]
— a list of custom fields
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getCustomFields(label)
Gets all the custom fields for this contact matching a particular field.
The label can be either a standard label from ContactsApp.ExtendedField or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the custom fields // associated with that contact that are in the ContactsApp.ExtendedField.HOBBY label. var contacts = ContactsApp.getContactsByName('John Doe'); var hobbies = contacts[0].getCustomFields(ContactsApp.ExtendedField.HOBBY); for (var i in hobbies) { Logger.log(hobbies[i].getValue()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.ExtendedField or a custom string |
Return
CustomField[]
— a list of custom fields
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getDates()
Gets all the dates for this contact.
// The code below retrieves a contact named "John Doe" and logs the label of the date // associated with that contact var contacts = ContactsApp.getContactsByName('John Doe'); var dates = contacts[0].getDates(); for (var i in dates) { Logger.log(dates[i].getLabel()); }
Return
DateField[]
— a list of dates
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getDates(label)
Gets all the dates for this contact matching a particular field.
The label can be either a standard label from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the day of the month // associated with that contact that are in the ContactsApp.Field.BIRTHDAY label. var contacts = ContactsApp.getContactsByName('John Doe'); var birthdays = contacts[0].getDates(ContactsApp.Field.BIRTHDAY); for (var i in birthdays) { Logger.log(birthdays[i].getDay()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
DateField[]
— a list of dates
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getEmails()
Gets the email addresses of this contact.
// The code below retrieves a contact named "John Doe" and logs the email addresses // associated with that contact var contacts = ContactsApp.getContactsByName('John Doe'); var emails = contacts[0].getEmails(); for (var i in emails) { Logger.log(emails[i].getAddress()); }
Return
EmailField[]
— the list of email addresses for the the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getEmails(label)
Gets the email addresses for this contact matching a particular field.
The label can be either a standard label from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the email addresses // associated with that contact that are in the ContactsApp.Field.HOME_EMAIL label. var contacts = ContactsApp.getContactsByName('John Doe'); var emails = contacts[0].getEmails(ContactsApp.Field.HOME_EMAIL); for (var i in emails) { Logger.log(emails[i].getAddress()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
EmailField[]
— the list of email addresses for the the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getFamilyName()
Gets the family name (last name) of the contact as a string.
// The code below logs the family name of all the contacts whose names contain "John" var contacts = ContactsApp.getContactsByName('John'); for (var i in contacts) { Logger.log(contacts[i].getFamilyName()); }
Return
String
— the family name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getFullName()
Gets the full name (given name and last name) of the contact as a string.
// The code below logs the full name of all the contacts whose names contain "John" var contacts = ContactsApp.getContactsByName('John'); for (var i in contacts) { Logger.log(contacts[i].getFullName()); }
Return
String
— the full name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getGivenName()
Gets the given name (first name) of the contact as a string.
// The code below logs the given name of all the contacts whose names contain "Smith" var contacts = ContactsApp.getContactsByName('Smith'); for (var i in contacts) { Logger.log(contacts[i].getGivenName()); }
Return
String
— the given name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getIMs()
Gets all the IM addresses for this contact.
// The code below logs the IM addresses of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getIMs()); }
Return
IMField[]
— a list of IM addresses
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getIMs(label)
Gets all the IM addresses for this contact matching a particular field.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the IM addresses // associated with that contact that are in the ContactsApp.Field.GOOGLE_TALK label. var contacts = ContactsApp.getContactsByName('John Doe'); var imAddresses = contacts[0].getIMs(ContactsApp.Field.GOOGLE_TALK); for (var i in imAddresses) { Logger.log(imAddresses[i].getAddress()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
IMField[]
— a list of IM addresses
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getId()
Returns the unique id of this contact.
var contact = ContactsApp.createContact('John', 'Doe', 'john.doe@example.com'); var id = contact.getId();
Return
String
— the id of this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getInitials()
Gets the contact's initials.
// The code below logs the initials of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getInitials()); }
Return
String
— the initials of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getLastUpdated()
Gets the date this contact was last updated.
// The code below logs the last updated date of all the contacts whose names contain // "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getLastUpdated()); }
Return
Date
— the date this contact was last updated
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getMaidenName()
Gets the maiden name of the contact as a string.
// The code below logs the maiden name of all the contacts whose names contain "Jane" var contacts = ContactsApp.getContactsByName('Jane'); for (var i in contacts) { Logger.log(contacts[i].getMaidenName()); }
Return
String
— the maiden name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getMiddleName()
Gets the middle name of the contact as a string.
// The code below logs the middle name of all the contacts whose names contain "Smith" var contacts = ContactsApp.getContactsByName('Smith'); for (var i in contacts) { Logger.log(contacts[i].getMiddleName()); }
Return
String
— the middle name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getNickname()
Gets the nickname of the contact as a string.
// The code below logs the nickname of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getNickname()); }
Return
String
— the nickname of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getNotes()
Gets the notes associated with this contact, or an empty string if there are no notes.
// The code below logs the notes of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getNotes()); }
Return
String
— the notes associated with this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getPhones()
Gets all the phone numbers for this contact.
// The code below logs the phone numbers of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getPhones()); }
Return
PhoneField[]
— a list of phone numbers
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getPhones(label)
Gets all the phone numbers for this contact matching a particular field.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the phone numbers // associated with that contact that are in the ContactsApp.Field.WORK_PHONE label. var contacts = ContactsApp.getContactsByName('John Doe'); var phones = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE); for (var i in phones) { Logger.log(phones[i].getPhoneNumber()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
PhoneField[]
— a list of phone numbers
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getPrefix()
Gets the prefix to the contact's name.
// The code below logs the prefix of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getPrefix()); }
Return
String
— the prefix of the contact's name
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getPrimaryEmail()
Gets the primary email address of the contact as a string.
// The code below logs the primary email address of all the contacts whose names contain // "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getPrimaryEmail()); }
Return
String
— the primary email address of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getShortName()
Gets the short name of the contact as a string.
// The code below logs the short name of all the contacts whose names contain "Johnathan" var contacts = ContactsApp.getContactsByName('Johnathan'); for (var i in contacts) { Logger.log(contacts[i].getShortName()); }
Return
String
— the short name of the contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getSuffix()
Gets the suffix to the contact's name.
// The code below logs the suffix of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getSuffix()); }
Return
String
— the suffix of the contact's name
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getUrls()
Gets all the URLs for this contact.
// The code below logs the URLs of all the contacts whose names contain "John Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { Logger.log(contacts[i].getUrls()); }
Return
UrlField[]
— a list of URLs
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getUrls(label)
Gets all the URLs for this contact matching a particular field.
The label can be either from ContactsApp.Field or a custom label string.
// The code below retrieves a contact named "John Doe" and logs the URLs // associated with that contact that are in the ContactsApp.Field.WORK_WEBSITE label. var contacts = ContactsApp.getContactsByName('John Doe'); var urls = contacts[0].getUrls(ContactsApp.Field.WORK_WEBSITE); for (var i in urls) { Logger.log(urls[i].getAddress()); }
Parameters
Name | Type | Description |
---|---|---|
label | Object | the label to match, either from ContactsApp.Field or a custom string |
Return
UrlField[]
— a list of URLs
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
removeFromGroup(group)
Removes this contact from the given contact group.
// The code below gets all the contacts named "John Doe" and then removes each of them from // the "Work Friends" contact group var contacts = ContactsApp.getContactsByName('John Doe'); var group = ContactsApp.getContactGroup('Work Friends'); for (var i in contacts) { contacts[i] = contacts[i].removeFromGroup(group); }
Parameters
Name | Type | Description |
---|---|---|
group | ContactGroup | the contact group to remove this contact from |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setFamilyName(familyName)
Sets the family name (last name) of the contact.
// The code below changes the family name of all the contacts whose names are "John Doe" // to "Doe-Smith" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setFamilyName('Doe-Smith'); }
Parameters
Name | Type | Description |
---|---|---|
familyName | String | the new family name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setFullName(fullName)
Sets the full name (given name and last name) of the contact.
// The code below changes the full name of all the contacts whose names are "John Doe" // to "Johnny Doe" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setFullName('Johnny Doe'); }
Parameters
Name | Type | Description |
---|---|---|
fullName | String | the new full name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setGivenName(givenName)
Sets the given name (first name) of the contact.
// The code below changes the given name of all the contacts whose names are "John Doe" // to "Johnny" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setGivenName('Johnny'); }
Parameters
Name | Type | Description |
---|---|---|
givenName | String | the new given name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setInitials(initials)
Sets the contact's initials.
// The code below sets the initials of all the contacts whose names are "Johnathan Doe" // to "JD" var contacts = ContactsApp.getContactsByName('Johnathan Doe'); for (var i in contacts) { contacts[i].setInitials('JD'); }
Parameters
Name | Type | Description |
---|---|---|
initials | String | the new initials of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setMaidenName(maidenName)
Sets the maiden name of the contact.
// The code below changes the maiden name of all the contacts whose names are "Jane Doe" // to "Smith" var contacts = ContactsApp.getContactsByName('Jane Doe'); for (var i in contacts) { contacts[i].setMaidenName('Smith'); }
Parameters
Name | Type | Description |
---|---|---|
maidenName | String | the new maiden name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setMiddleName(middleName)
Sets the middle name of the contact.
// The code below changes the middle name of all the contacts whose names are "John Doe" // to "Danger" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setMiddleName('Danger'); }
Parameters
Name | Type | Description |
---|---|---|
middleName | String | the new middle name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setNickname(nickname)
Sets the nickname of the contact.
// The code below changes the nickname of all the contacts whose names are "John Doe" // to "JohnnyD" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setNickname('JohnnyD'); }
Parameters
Name | Type | Description |
---|---|---|
nickname | String | the new nickname of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setNotes(notes)
Sets the notes associated with this contact.
// The code below sets the notes of all the contacts whose names are "John Doe" // to "Met him at the hackathon" var contacts = ContactsApp.getContactsByName('John Doe'); for (var i in contacts) { contacts[i].setNotes('Met him at the hackathon'); }
Parameters
Name | Type | Description |
---|---|---|
notes | String | the notes to be stored for this contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setPrefix(prefix)
Sets the prefix to the contact's name.
// The code below sets the prefix of all the contacts whose names are "Johnathan Doe" // to "Mr" var contacts = ContactsApp.getContactsByName('Johnathan Doe'); for (var i in contacts) { contacts[i].setPrefix('Mr'); }
Parameters
Name | Type | Description |
---|---|---|
prefix | String | the new prefix of the contact's name |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setShortName(shortName)
Sets the short name of the contact.
// The code below changes the short name of all the contacts whose names are "Johnathan Doe" // to "John" var contacts = ContactsApp.getContactsByName('Johnathan Doe'); for (var i in contacts) { contacts[i].setShortName('John'); }
Parameters
Name | Type | Description |
---|---|---|
shortName | String | the new short name of the contact |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
setSuffix(suffix)
Sets the suffix to the contact's name.
// The code below sets the suffix of all the contacts whose names are "Johnathan Doe" // to "Jr" var contacts = ContactsApp.getContactsByName('Johnathan Doe'); for (var i in contacts) { contacts[i].setSuffix('Jr'); }
Parameters
Name | Type | Description |
---|---|---|
suffix | String | the new suffix of the contact's name |
Return
Contact
— this contact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds