Class ContactGroup

  • The ContactGroup class 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.

ContactGroup

Deprecated. Instead, use the People API advanced service

A ContactGroup is is a group of contacts.

Deprecated methods

MethodReturn typeBrief description
(削除) addContact(contact) (削除ここまで)(削除) ContactGroup (削除ここまで)Adds the given contact to this group
// The code below creates a new contact and adds it to the "Work Friends"
// contact group
constcontact=ContactsApp.createContact(
'John',
'Doe',
'john.doe@example.com',
);
constgroup=ContactsApp.getContactGroup('Work Friends');
group.addContact(contact);
(削除) deleteGroup() (削除ここまで)voidDeletes this contact group.
(削除) getContacts() (削除ここまで)(削除) Contact[] (削除ここまで)Gets all the contacts in this contact group.
(削除) getGroupName() (削除ここまで)StringReturns the name of this group.
(削除) getId() (削除ここまで)StringGets the id of this contact group.
(削除) getName() (削除ここまで)StringGets the name of this contact group.
(削除) isSystemGroup() (削除ここまで)BooleanGets a boolean value to determine whether this contact group is a system group (undeletable) or not.
(削除) removeContact(contact) (削除ここまで)(削除) ContactGroup (削除ここまで)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 group
constcontacts=ContactsApp.getContactsByName('John Doe');
constgroup=ContactsApp.getContactGroup('Work Friends');
for(constiincontacts){
group.removeContact(contacts[i]);
}
(削除) setGroupName(name) (削除ここまで)voidSets the name of this group.
(削除) setName(name) (削除ここまで)(削除) ContactGroup (削除ここまで)Sets the name of this contact group.

Deprecated methods

(削除) 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 group
constcontact=ContactsApp.createContact(
'John',
'Doe',
'john.doe@example.com',
);
constgroup=ContactsApp.getContactGroup('Work Friends');
group.addContact(contact);

Parameters

NameTypeDescription
contact(削除) Contact (削除ここまで)the contact to be added to the group

Return

(削除) ContactGroup (削除ここまで) — this contact group

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


(削除) 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 it
constgroup=ContactsApp.getContactGroup('Work Friends');
group.deleteGroup();

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


(削除) 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

(削除) Contact[] (削除ここまで) — the contacts in this group

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

(削除) 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 following scopes:

  • https://www.google.com/m8/feeds

(削除) 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 id
constgroup=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 following scopes:

  • https://www.google.com/m8/feeds

(削除) 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 name
constgroup=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 following scopes:

  • https://www.google.com/m8/feeds

See also


(削除) 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) or not.

Systems groups are a set of groups that are predefined in Google Contacts, such as "My Contacts", "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 following scopes:

  • https://www.google.com/m8/feeds

(削除) 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 group
constcontacts=ContactsApp.getContactsByName('John Doe');
constgroup=ContactsApp.getContactGroup('Work Friends');
for(constiincontacts){
group.removeContact(contacts[i]);
}

Parameters

NameTypeDescription
contact(削除) Contact (削除ここまで)the contact to be removed from the group

Return

(削除) ContactGroup (削除ここまで) — this contact group

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


(削除) setGroupName(name) (削除ここまで)

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the name of this group.

Parameters

NameTypeDescription
nameStringthe name to set for this group

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

(削除) 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

NameTypeDescription
nameStringthe new name for the contact group

Return

(削除) ContactGroup (削除ここまで) — this contact group

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年12月11日 UTC.