Field
A field belonging to a table in your base. Each table has at least one field.
Get fields using table.getField().
let table = base.getTable("Tasks");let field = table.getField("Description");console.log(field);
id
string
The unique ID of this field.
// Show a field idlet table = base.getTable("Projects");let field = table.getField("Category");console.log(`Field id: ${field.id}`);
name
string
The name of the field.
// Show a field namelet table = base.getTable("People");let field = table.getField("Role");console.log(`Field name: ${field.name}`);
description
string | null
The description of this field, if it has one.
// Show a field descriptionlet table = base.getTable("People");let field = table.getField("Role");console.log(`Field description: ${field.description}`);
type
'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.
// 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
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.
// 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
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.).
// show whether or not each field in "People" is computedfor (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
(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.
let table = base.getTable("Projects");let field = table.getField("Category");await field.updateDescriptionAsync('New description');
updateOptionsAsync Scripting Extension only
(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 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.
const table = base.getTable("Tasks");const selectField = table.getField("Priority");await selectField.updateOptionsAsync({choices: [...field.options.choices, {name: "Urgent"}],});
updateNameAsync Scripting Extension only
(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.
let table = base.getTable("Projects");let field = table.getField("Category");await field.updateNameAsync('New name');