ContactGroup


**Deprecated.** Instead, use the [People API advanced
service](https://developers.google.com/apps-script/advanced/people)

A ContactGroup is is a group of contacts.

### Deprecated methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/contacts/contact-group#addContact(Contact)` | `https://developers.google.com/apps-script/reference/contacts/contact-group#` | Adds the given contact to this group ```javascript // The code below creates a new contact and adds it to the "Work Friends" // contact group const contact = ContactsApp.createContact( 'John', 'Doe', 'john.doe@example.com', ); const group = ContactsApp.getContactGroup('Work Friends'); group.addContact(contact); ``` |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#deleteGroup()` | `void` | Deletes this contact group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#getContacts()` | `https://developers.google.com/apps-script/reference/contacts/contact` | Gets all the contacts in this contact group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#getGroupName()` | `String` | Returns the name of this group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#getId()` | `String` | Gets the id of this contact group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#getName()` | `String` | Gets the name of this contact group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#isSystemGroup()` | `Boolean` | Gets a boolean value to determine whether this contact group is a system group (undeletable) or not. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#removeContact(Contact)` | `https://developers.google.com/apps-script/reference/contacts/contact-group#` | Removes the given contact from this group ```javascript // The code below retrieves all the contacts named "John Doe' and removes them // from the "Work Friends" contact group const contacts = ContactsApp.getContactsByName('John Doe'); const group = ContactsApp.getContactGroup('Work Friends'); for (const i in contacts) { group.removeContact(contacts[i]); } ``` |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#setGroupName(String)` | `void` | Sets the name of this group. |
| `https://developers.google.com/apps-script/reference/contacts/contact-group#setName(String)` | `https://developers.google.com/apps-script/reference/contacts/contact-group#` | 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

```javascript
// The code below creates a new contact and adds it to the "Work Friends"
// contact group
const contact = ContactsApp.createContact(
    'John',
    'Doe',
    'john.doe@example.com',
);
const group = ContactsApp.getContactGroup('Work Friends');
group.addContact(contact);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `contact` | `https://developers.google.com/apps-script/reference/contacts/contact` | the contact to be added to the group |

#### Return


`https://developers.google.com/apps-script/reference/contacts/contact-group#` --- this contact group

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.google.com/m8/feeds`

#### See also

- `https://developers.google.com/apps-script/reference/contacts/contact-group#removeContact(Contact)`

*** ** * ** ***

### `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.

```javascript
// The code below retrieves a contact group named "Work Friends" and deletes it
const group = ContactsApp.getContactGroup('Work Friends');
group.deleteGroup();
```

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.google.com/m8/feeds`

#### See also

- `https://developers.google.com/apps-script/reference/contacts/contact-group#isSystemGroup()`

*** ** * ** ***

### `getContacts()`


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

Gets all the contacts in this contact group.

```javascript
// The code below retrieves all the contacts in the group named "Work Friends"
const group = ContactsApp.getContactGroup('Work Friends');
const contacts = group.getContacts();
```

#### Return


`https://developers.google.com/apps-script/reference/contacts/contact` --- the contacts in this group

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_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://developers.google.com/apps-script/concepts/scopes#setting_explicit_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.

```javascript
// The code below retrieves a contact group named "Work Friends" and gets its id
const group = ContactsApp.getContactGroup('Work Friends');
const id = 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://developers.google.com/apps-script/concepts/scopes#setting_explicit_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.

```javascript
// The code below creates a new contact group and then retrieves its name
const group = ContactsApp.createContactGroup('Work Friends');
const name = 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://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.google.com/m8/feeds`

#### See also

- `https://developers.google.com/apps-script/reference/contacts/contact-group#setName(String)`

*** ** * ** ***

### `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".

```javascript
// The code below retrieves two contact groups, then logs whether or not
// each is a system group.
const myGroup = ContactsApp.getContactGroup('Work Friends');
const systemGroup = 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://developers.google.com/apps-script/concepts/scopes#setting_explicit_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

```javascript
// The code below retrieves all the contacts named "John Doe' and removes them
// from the "Work Friends" contact group
const contacts = ContactsApp.getContactsByName('John Doe');
const group = ContactsApp.getContactGroup('Work Friends');
for (const i in contacts) {
  group.removeContact(contacts[i]);
}
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `contact` | `https://developers.google.com/apps-script/reference/contacts/contact` | the contact to be removed from the group |

#### Return


`https://developers.google.com/apps-script/reference/contacts/contact-group#` --- this contact group

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.google.com/m8/feeds`

#### See also

- `https://developers.google.com/apps-script/reference/contacts/contact-group#addContact(Contact)`

*** ** * ** ***

### `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 following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_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.

```javascript
// The code below retrieves the contact group named "Work Friends" and renames
// it to "Work Buddies"
const group = ContactsApp.getContactGroup('Work Friends');
group.setName('Work Buddies');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | the new name for the contact group |

#### Return


`https://developers.google.com/apps-script/reference/contacts/contact-group#` --- this contact group

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.google.com/m8/feeds`

#### See also

- `https://developers.google.com/apps-script/reference/contacts/contact-group#getName()`