# Class PhoneField

PhoneField


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

A phone number field in a Contact.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `getLabel()` | `Object` | Gets the label for this field. |
| `isPrimary()` | `Boolean` | Gets whether this is the primary field value. |
| `setAsPrimary()` | `PhoneField` | Sets this field to primary. |
| `setLabel(field)` | `PhoneField` | Sets the label of this field. |
| `setLabel(label)` | `PhoneField` | Sets the label of this field. |

### Deprecated methods

| Method | Return type | Brief description |
|---|---|---|
| `deletePhoneField()` | `void` | Deletes this phone number field. |
| `getPhoneNumber()` | `String` | Get the phone number for this field. |
| `setPhoneNumber(number)` | `PhoneField` | Sets the phone number for this field. |

## Detailed documentation

### `getLabel()`

Gets the label for this field. This may be a Field, ExtendedField, or a String.

```javascript
// Logs the label for all the address fields associated with contact
// 'John Doe'. This method can be similarly called for any field that has
// a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
for (let i = 0; i < addressFields.length; i++) {
  Logger.log(addressFields[i].getLabel());
}
```

#### Return


`Object` --- the label for this field

#### Authorization

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

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

*** ** * ** ***

### `isPrimary()`

Gets whether this is the primary field value.

```javascript
// Logs whether or not the first address field associated with contact
// 'John Doe' is labeled as primary. This method can be similarly called
// for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
Logger.log(addressFields[0].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.md.txt#setting_explicit_scopes):

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

*** ** * ** ***

### `setAsPrimary()`

Sets this field to primary.

```javascript
// Sets the first address field associated with contact 'John Doe'
// as primary. This method can be similarly called for any field.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setAsPrimary();
```

#### Return


`PhoneField` --- this FieldValue 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.md.txt#setting_explicit_scopes):

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

*** ** * ** ***

### `setLabel(field)`

Sets the label of this field.

```javascript
// Sets the label to 'Work' for the first address field associated
// with contact 'John Doe'. This method can be similarly called for any
// field that has a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `field` | `Field` | the new standard label |

#### Return


`PhoneField` --- this FieldValue 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.md.txt#setting_explicit_scopes):

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

*** ** * ** ***

### `setLabel(label)`

Sets the label of this field.

```javascript
// Sets the label to 'Apartment' for the first address field associated
// with contact 'John Doe'. This method can be similarly called for any
// field that has a label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `label` | `String` | the new label for this field |

#### Return


`PhoneField` --- this 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.md.txt#setting_explicit_scopes):

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

## Deprecated methods

### `deletePhoneField()`


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

Deletes this phone number field.

```javascript
// Retrieves and deletes the work phone number field for contact 'John
// Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
phoneFields[0].deletePhoneField();
```

#### Authorization

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

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

*** ** * ** ***

### `getPhoneNumber()`


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

Get the phone number for this field.

```javascript
// Logs the work phone number for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
Logger.log(phoneFields[0].getPhoneNumber());
```

#### Return


`String` --- the number as a string

#### Authorization

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

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

*** ** * ** ***

### `setPhoneNumber(number)`


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

Sets the phone number for this field.

```javascript
// Sets the work phone number for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const phoneFields = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
phoneFields[0].setPhoneNumber('212-555-1234');
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `number` | `String` | the new number |

#### Return


`PhoneField` --- this 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.md.txt#setting_explicit_scopes):

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