
## Field

A field belonging to a [table](/developers/scripting/api/table.md) in your [base](/developers/scripting/api/base.md). Each table has at least one
field.

Get fields using [table.getField()](/developers/scripting/api/table.md#get-field).

```js
let table = base.getTable("Tasks");
let field = table.getField("Description");
console.log(field);
```

### id

```js
string
```

The unique ID of this field.

```js
// Show a field id
let table = base.getTable("Projects");
let field = table.getField("Category");
console.log(`Field id: ${field.id}`);
```

### name

```js
string
```

The name of the field.

```js
// Show a field name
let table = base.getTable("People");
let field = table.getField("Role");
console.log(`Field name: ${field.name}`);
```

### description

```js
string | null
```

The description of this field, if it has one.

```js
// Show a field description
let table = base.getTable("People");
let field = table.getField("Role");
console.log(`Field description: ${field.description}`);
```

### type

```js
'singleLineText' | 'email' | 'url' | 'multilineText' | 'number' | 'percent' | 'currency' | 'singleSelect' | 'multipleSelects' | 'singleCollaborator' | 'multipleCollaborators' | 'multipleRecordLinks' | 'date' | 'dateTime' | 'phoneNumber' | 'multipleAttachments' | 'checkbox' | 'formula' | 'createdTime' | 'rollup' | 'count' | 'multipleLookupValues' | 'autoNumber' | 'barcode' | 'rating' | 'richText' | 'duration' | 'lastModifiedTime' | 'externalSyncSource'
```

The type of the field, such as Email, Percent, or Linked Records. See
[cell values & field options](/developers/scripting/api/cell_values.md) for more information on the available field types.

```js
// show the type of every field in "Tasks"
for (let field of base.getTable("Tasks").fields) {
    console.log(`Field "${field.name}" has type "${field.type}".`);
}
```

### options

```js
null | unknown
```

The configuration options of the field. The structure of the field's options depend on the field's
type. See [cell values & field options](/developers/scripting/api/cell_values.md) for the options structure of each field
type.

```js
// show the options of every field in "Projects"
for (let field of base.getTable("Projects").fields) {
    console.log(`Field "${field.name}" (${field.type}) options:`);
    console.log(field.options);
}
```

### isComputed

```js
boolean
```

`true` if this field is computed, `false` otherwise. A field is "computed" if it's value is not
set by user input (e.g. autoNumber, formula, etc.).

```js
// show whether or not each field in "People" is computed
for (let field of base.getTable("People").fields) {
    if (field.isComputed) {
        console.log(`Field "${field.name}" is computed`);
    } else {
        console.log(`Field "${field.name}" is not computed`);
    }
}
```

### updateDescriptionAsync

```js
(description: string | null) => Promise<void>
```

| Parameter name | Description |
|---|---|
| `description` | New description for the field. |

Updates the description for this field.

To remove an existing description, pass `''` as the new description.
`null` is also accepted and will be coerced to `''` for consistency with field creation.

Throws an error if the user does not have permission to update the field, or if invalid description
is provided.

This action is asynchronous: you must add `await` before each call to this method to ensure it
takes effect.


```js
let table = base.getTable("Projects");
let field = table.getField("Category");
await field.updateDescriptionAsync('New description');
```


### updateOptionsAsync (extensions only)

```js
(options: {[key: string]: unknown}) => Promise<void>
```

| Parameter name | Description |
|---|---|
| `options` | New options for the field. |

Updates the options for this field.

Throws an error if the user does not have permission to update the field, if invalid options are
provided, if this field has no writable options, or if updates to this field type is not supported.
See [Cell values & field options](/developers/scripting/api/cell_values.md) for the options format for each field type.

This action is asynchronous: you must add `await` before each call to this method to ensure it
takes effect.


```js
const table = base.getTable("Tasks");
const selectField = table.getField("Priority");
await selectField.updateOptionsAsync({
    choices: [...field.options.choices, {name: "Urgent"}],
});
```

### updateNameAsync (extensions only)

```js
(name: string) => Promise<void>
```

| Parameter name | Description |
|---|---|
| `name` | New name for the field. |

Updates the name for this field.

Throws an error if the user does not have permission to update the field, or if invalid name
is provided.

This action is asynchronous: you must add `await` before each call to this method to ensure it
takes effect.


```js
let table = base.getTable("Projects");
let field = table.getField("Category");
await field.updateNameAsync('New name');
```
