CompanyField


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

Company field in a Contact.

### Deprecated methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/contacts/company-field#deleteCompanyField()` | `void` | Deletes this company field. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#getCompanyName()` | `String` | Gets the company name. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#getJobTitle()` | `String` | Gets the job title. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#isPrimary()` | `Boolean` | Gets whether this is the primary company. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#setAsPrimary()` | `https://developers.google.com/apps-script/reference/contacts/company-field#` | Sets this company as the primary company, and unsets whatever company was previously primary. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#setCompanyName(String)` | `https://developers.google.com/apps-script/reference/contacts/company-field#` | Sets the company name. |
| `https://developers.google.com/apps-script/reference/contacts/company-field#setJobTitle(String)` | `https://developers.google.com/apps-script/reference/contacts/company-field#` | Sets the job title. |

## Deprecated methods

### `deleteCompanyField()`


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

Deletes this company field.

```javascript
// Deletes the first company associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.deleteCompanyField();
```

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

*** ** * ** ***

### `getCompanyName()`


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

Gets the company name.

```javascript
// Logs company name for all companies associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
  Logger.log(companies[i].getCompanyName());
}
```

#### Return


`String` --- the name of the company

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

*** ** * ** ***

### `getJobTitle()`


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

Gets the job title.

```javascript
// Logs job title for all companies associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
  Logger.log(companies[i].getJobTitle());
}
```

#### Return


`String` --- the job title

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

*** ** * ** ***

### `isPrimary()`


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

Gets whether this is the primary company.

```javascript
// Logs true or false depending on whether each company is the primary
// company for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
  Logger.log(companies[i].isPrimary());
}
```

#### Return


`Boolean` --- whether this is primary

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

*** ** * ** ***

### `setAsPrimary()`


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

Sets this company as the primary company, and unsets whatever company was previously primary.

```javascript
// Sets the first company associated with contact 'John Doe' as primary
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setAsPrimary();
```

#### Return


`https://developers.google.com/apps-script/reference/contacts/company-field#` --- this company field, useful for chaining

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

*** ** * ** ***

### `setCompanyName(company)`


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

Sets the company name.

```javascript
// Sets the company name for the first company associated with contact 'John
// Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setCompanyName('ACME Corp');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `company` | `String` | the new name for the company |

#### Return


`https://developers.google.com/apps-script/reference/contacts/company-field#` --- this company field, useful for chaining

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

*** ** * ** ***

### `setJobTitle(title)`


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

Sets the job title.

```javascript
// Sets the job title for the first company associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setJobTitle('Manager');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `title` | `String` | the new job title for the contact at this company |

#### Return


`https://developers.google.com/apps-script/reference/contacts/company-field#` --- this company field, useful for chaining

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