Table
Defines a database table (sys_db_object) in a scoped application with typed column schemas, auto-numbering, access controls, and table inheritance.
Signature
Table(table)
Parameters
table
T & Table<S, E>
Note: The SDK no longer derives defaults for the access properties --
actions,allowClientScripts,allowConfiguration,allowNewFields,allowUiActions, andallowWebServiceAccess. Each one is written to the table's metadata only if you set it in Fluent.
Properties:
-
name (required unless
augmentsis set):stringName of the table. Must be lowercase and include the application scope prefix. -
schema (required):
Record<string, Column>Array of column references that define the table's schema -
accessibleFrom (optional):
'public' | 'package_private'Controls whether other application scopes can access the table. Default ispublic. Usepackage_privateonly when you need to restrict cross-scope read access. This will prevent the table from being selectable in some platform features such as Business Rules. -
actions (optional):
TableActionAccessAccess options for the table. Only enablecreate,update, ordeleteif cross-scope write access is explicitly required.TableActionAccesshas:- read (optional):
boolean— Allows records in the table to be read. - update (optional):
boolean— Allows records in the table to be updated. - delete (optional):
boolean— Allows records in the table to be deleted. - create (optional):
boolean— Allows records to be created in the table.
- read (optional):
-
allowClientScripts (optional):
booleanIndicates whether to allow design time configuration of client scripts on the table from other application scopes. -
allowConfiguration (optional):
booleanIndicates whether to allow design time configuration of the table itself from other application scopes. Corresponds to the "Allow configuration" field on the Application Access form. Left unset when omitted, so the platform inherits the value from the table's parent. -
allowNewFields (optional):
booleanIndicates whether to allow design time configuration of new fields on the table from other application scope. -
allowUiActions (optional):
booleanIndicates whether to allow design time configuration of UI Actions on the table from other application scopes. -
allowWebServiceAccess (optional):
booleanIndicates whether web services can make calls to the table. Must be set totruefor the table to be accessible via the Table API (/api/now/table) or other REST integrations -- otherwise requests return 403. -
attributes (optional):
Record<string, string | number | boolean>Pairs of any supported dictionary attributes (sys_schema_attribute). -
audit (optional):
booleanIndicates whether to track the creation, update, and deletion of all records in the table. -
augments (optional):
stringThe name of an existing table to augment (e.g.'incident') to augment by adding columns. When set, onlyschemaandindexare configurable, all other table-level properties (name,extends,label,display,audit, etc.) are not permitted. Use this to extend platform or cross-scope tables. -
autoNumber (optional):
objectAuto-increment configuration for the tables with a 'number' column. Do not use if table does not have (or inherit) a 'number' column.-
number:
number -
numberOfDigits:
number -
prefix:
string
-
-
callerAccess (optional):
'none' | 'tracking' | 'restricted'Access level for cross-scope requests. -
display (optional):
stringDefault display column. Use a column name from the schema. -
extends (optional):
keyof TablesThe name of any other table on which this table is based. -
extensible (optional):
booleanIndicates whether other tables can extend this table. -
index (optional):
object[]A list of column references to generate indexes in the metadata XML of the table. Each entry has:- name (optional):
string— Name of the index. - unique (required):
boolean— Whether the index enforces uniqueness. - element (required):
string | string[]— Column name(s) that make up the index.
- name (optional):
-
label (optional):
string | Documentation[]A unique label for the table on list and form views. -
licensingConfig (optional):
LicensingConfigConfiguration for table licensing. -
liveFeed (optional):
booleanIndicates if live feeds are available for records in the table. -
readOnly (optional):
booleanIndicates whether users can edit fields in the table. -
scriptableTable (optional):
booleanIndicates whether the table is a remote table that uses data retrieved from an external source. -
sizeClass (optional):
numberSize classification of the table. Used to indicate the expected size category of the table. -
dbObjectId (optional):
booleanWrites the table'ssys_idto thedb_object_idattribute of the generated bootstrap dictionary XML, pinning thesys_db_objectrecord the platform creates for this table to thatsys_idinstead of letting it generate one. Set this when the table'ssys_idmust stay stable across installs, for example when other metadata references thesys_db_objectrecord directly. Defaults tofalse. Not permitted alongsideaugments. -
createAccessControls (optional):
booleanIndicates whether to create access controls when the table is created. -
userRole (optional):
string | Role | Record<'sys_user_role'>Role used to wire the table's auto-generated access controls. Accepts a role name (created on-demand via the platform'sdynamic_creationscript if it does not yet exist) or a reference to an existingsys_user_rolerecord. When omitted, the platform falls back to the parent application'suser_role. Only takes effect whencreateAccessControlsistrue. -
textIndex (optional):
booleanIndicates whether search engines index the text in a table.
See
Examples
To-Do Table Example
import { Table, StringColumn, DateColumn, IntegerColumn } from '@servicenow/sdk/core'
// Variable name MUST match the name property
export const x_snc_example_to_do = Table({
name: 'x_snc_example_to_do',
label: 'My To Do Table',
display: 'title', // Use the 'title' column as the display column
schema: {
title: StringColumn({ mandatory: true }),
deadline: DateColumn({ label: 'Deadline' }),
status: StringColumn({
label: 'Status',
choices: {
ready: 'Ready',
in_progress: 'In Progress',
completed: 'Completed',
},
}),
},
})
Extending Task Example
import { Table, StringColumn, DateColumn, IntegerColumn } from '@servicenow/sdk/core'
// Variable name MUST match the name property
export const x_snc_example_task = Table({
name: 'x_snc_example_color_task',
label: 'My Color Task',
extends: 'task', // Inherit columns from the 'task' table
schema: {
color: StringColumn({
label: 'Color',
choices: {
red: 'Red',
blue: 'Blue',
green: 'Green',
},
}),
},
// Configure auto-incrementation for the inherited 'number' column from the parent 'task' table (e.g. CLR0000001, CLR0000002, etc)
autoNumber: {
prefix: 'CLR',
number: 2000,
numberOfDigits: 7,
},
})
Cross-Scope Access Example
A table other scoped apps can read, create, and update.
import { Table, StringColumn } from '@servicenow/sdk/core'
export const x_snc_example_case = Table({
name: 'x_snc_example_case',
label: 'Example Case',
extends: 'sn_customerservice_case',
accessibleFrom: 'public',
callerAccess: 'tracking',
actions: { read: true, create: true, update: true },
schema: {
reason: StringColumn({ label: 'Reason' }),
},
})
Override Inherited Columns
/**
* @title Override Inherited Columns
* @description Examples of overriding inherited column properties in child tables
*/
import { Table, OverrideColumn, StringColumn, ReferenceColumn } from '@servicenow/sdk/core'
// Example 2: Override multiple properties
export const x_override_multiple = Table({
name: 'x_override_multiple',
extends: 'task',
schema: {
priority: OverrideColumn({
baseTable: 'task',
mandatory: true,
default: '1',
}),
state: OverrideColumn({
baseTable: 'task',
mandatory: true,
readOnlyOption: 'display_read_only',
}),
description: OverrideColumn({
baseTable: 'task',
display: false,
}),
},
})
For guidance on table creation, column types, relationships, and common pitfalls, see the table-guide topic.