Scripting
Model

Field

A field belonging to a table in your base. Each table has at least one field.

Get fields using table.getField().

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

id

typedef
string

The unique ID of this field.

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

name

typedef
string

The name of the field.

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

description

typedef
string | null

The description of this field, if it has one.

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

type

typedef
'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 for more information on the available field types.

Example
// 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

typedef
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 for the options structure of each field type.

Example
// 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

typedef
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.).

Example
// 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

function
(description: string | null) => Promise<void>
Parameter nameDescription
descriptionNew 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.

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

updateOptionsAsync
Scripting Extension only

function
(options: {[key: string]: unknown}) => Promise<void>
Parameter nameDescription
optionsNew 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 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.

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

updateNameAsync
Scripting Extension only

function
(name: string) => Promise<void>
Parameter nameDescription
nameNew 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.

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