Class ContactGroup Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
ContactGroupclass is deprecated and should be replaced by the People API advanced service.A ContactGroup represents a group of contacts.
The methods associated with ContactGroup, such as adding or removing contacts, deleting groups, and getting group information, are also deprecated.
Deprecated. Instead, use thePeople API advanced service
A ContactGroup is is a group of contacts.
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| | Adds the given contact to this group// The code below creates a new contact and adds it to the "Work Friends"// contact groupconstcontact=ContactsApp.createContact('John','Doe','john.doe@example.com',);constgroup=ContactsApp.getContactGroup('Work Friends');group.addContact(contact); |
| void | Deletes this contact group. |
| | Gets all the contacts in this contact group. |
| String | Returns the name of this group. |
| String | Gets the id of this contact group. |
| String | Gets the name of this contact group. |
| Boolean | Gets a boolean value to determine whether this contact group is a system group (undeletable) ornot. |
| | Removes the given contact from this group// The code below retrieves all the contacts named "John Doe' and removes them// from the "Work Friends" contact groupconstcontacts=ContactsApp.getContactsByName('John Doe');constgroup=ContactsApp.getContactGroup('Work Friends');for(constiincontacts){group.removeContact(contacts[i]);} |
| void | Sets the name of this group. |
| | Sets the name of this contact group. |
Deprecated methods
addContact(contact)
addContact(contact) Deprecated. This function is deprecated and should not be used in new scripts.
Adds the given contact to this group
// The code below creates a new contact and adds it to the "Work Friends"// contact groupconstcontact=ContactsApp.createContact('John','Doe','john.doe@example.com',);constgroup=ContactsApp.getContactGroup('Work Friends');group.addContact(contact);
Parameters
| Name | Type | Description |
|---|---|---|
contact | | the contact to be added to the group |
Return
— this contact groupContact
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
See also
deleteGroup()
deleteGroup() Deprecated. This function is deprecated and should not be used in new scripts.
Deletes this contact group.
Deletes non-system groups only; system groups cannot be deleted.
// The code below retrieves a contact group named "Work Friends" and deletes itconstgroup=ContactsApp.getContactGroup('Work Friends');group.deleteGroup();
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
See also
getContacts()
getContacts() Deprecated. This function is deprecated and should not be used in new scripts.
Gets all the contacts in this contact group.
// The code below retrieves all the contacts in the group named "Work Friends"constgroup=ContactsApp.getContactGroup('Work Friends');constcontacts=group.getContacts();
Return
— the contacts in this groupContact[]
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
getGroupName()
getGroupName() Deprecated. This function is deprecated and should not be used in new scripts.
Returns the name of this group.
Return
String — the name of this group
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
getId()
getId() Deprecated. This function is deprecated and should not be used in new scripts.
Gets the id of this contact group.
// The code below retrieves a contact group named "Work Friends" and gets its idconstgroup=ContactsApp.getContactGroup('Work Friends');constid=group.getId();
Return
String — the id of this group
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
getName()
getName() Deprecated. This function is deprecated and should not be used in new scripts.
Gets the name of this contact group.
// The code below creates a new contact group and then retrieves its nameconstgroup=ContactsApp.createContactGroup('Work Friends');constname=group.getName();
Return
String — this name of this contact group
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
See also
isSystemGroup()
isSystemGroup() Deprecated. This function is deprecated and should not be used in new scripts.
Gets a boolean value to determine whether this contact group is a system group (undeletable) ornot.
Systems groups are a set of groups that are predefined in Google Contacts, such as "MyContacts", "Family", "Coworkers", etc. The name of a system group usually contains the words"System Group".
// The code below retrieves two contact groups, then logs whether or not// each is a system group.constmyGroup=ContactsApp.getContactGroup('Work Friends');constsystemGroup=ContactsApp.getContactGroup('System Group: Coworkers');Logger.log(myGroup.isSystemGroup());// Returns false, if the group exists.Logger.log(systemGroup.isSystemGroup());// Returns true.
Return
Boolean — whether or not this contact group is a system group
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
removeContact(contact)
removeContact(contact) Deprecated. This function is deprecated and should not be used in new scripts.
Removes the given contact from this group
// The code below retrieves all the contacts named "John Doe' and removes them// from the "Work Friends" contact groupconstcontacts=ContactsApp.getContactsByName('John Doe');constgroup=ContactsApp.getContactGroup('Work Friends');for(constiincontacts){group.removeContact(contacts[i]);}
Parameters
| Name | Type | Description |
|---|---|---|
contact | | the contact to be removed from the group |
Return
— this contact groupContact
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
See also
setGroupName(name)
setGroupName(name) Deprecated. This function is deprecated and should not be used in new scripts.
Sets the name of this group.
Parameters
| Name | Type | Description |
|---|---|---|
name | String | the name to set for this group |
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
setName(name)
setName(name) Deprecated. This function is deprecated and should not be used in new scripts.
Sets the name of this contact group.
// The code below retrieves the contact group named "Work Friends" and renames// it to "Work Buddies"constgroup=ContactsApp.getContactGroup('Work Friends');group.setName('Work Buddies');
Parameters
| Name | Type | Description |
|---|---|---|
name | String | the new name for the contact group |
Return
— this contact groupContact
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.google.com/m8/feeds
See also
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.