ReferenceColumn
Defines a reference (foreign key) column that links a record to a row in another table. Use referenceTable to specify the target table and cascadeRule to control what happens to referencing records when the target is deleted.
Signature
ReferenceColumn(config)
Parameters
config
C & ReferenceColumnType<RefTable, Type, Default>
Properties:
-
referenceTable (required):
RefTableReference a different table as string, escape with `` if definition not present locally (import from@servicenow/sdk-core/global) -
active (optional):
booleanIndicates whether to display the field in list and forms -
array (optional):
booleanCreates another table to store the info that will be captured by this field -
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. -
cascadeRule (optional):
'none' | 'delete_no_workflow' | 'cascade' | 'delete' | 'restrict' | 'clear'Configure what happens to records that reference a record when that record is deleted. -
default (optional):
Default | stringDefault value of the field when creating a record -
dependent (optional):
stringlimit the values available to select based on the value of the dependent field -
dynamicCreation (optional):
booleanIf a reference is not found for a reference field then it allows the creation of that target -
dynamicCreationScript (optional):
stringPopulate a new record from a reference field based on the field value -
dynamicRefQual (optional):
Record<'sys_filter_option_dynamic'> | stringReference to asys_filter_option_dynamicrecord — see thenow-refguide for record-reference forms. Use withuseReferenceQualifier: 'dynamic'. Mutually exclusive withreferenceQual. -
elementReference (optional):
booleanIndicates if the value of this field connotes the "element type" -
functionDefinition (optional):
stringDefinition of a function that the field performs -
help (optional):
stringHelp information for the field -
hint (optional):
stringDescribes field in more verbose form -
label (optional):
string | Documentation[]Unique label for the column that appears on list headers and form fields -
mandatory (optional):
booleanIndicates whether the field must contain a value to save a record -
maxLength (optional):
number | stringMaximum length of the field value -
plural (optional):
stringPlural form of the field name -
primary (optional):
booleanIndicates the primary key for a table -
readOnly (optional):
booleanIndicates whether you can edit the field value -
readOnlyOption (optional):
readOnlyOptionTypeSpecifies the read-only behavior for the field -
referenceFloats (optional):
booleanReferenced table's form has an "edit" button in the related list for the current table -
referenceKey (optional):
stringSets up a many to many relationship. The value specified is the label describing the relationship. -
referenceQual (optional):
stringFilter condition for the reference picker. Can be a simple encoded query (e.g.,'active=true') or a JavaScript expression prefixed withjavascript:(e.g.,"javascript:'active=true^department=' + current.getValue('department')"). Mutually exclusive withdynamicRefQual. Maps tosys_dictionary.reference_qual. -
spellCheck (optional):
booleanEnables spell check for this field -
tableReference (optional):
booleanIndicates if the value of this field is a reference to another table in the schema -
textIndex (optional):
booleanEnables a natural language search on this field -
unique (optional):
booleanCreates a unique index on this field -
useReferenceQualifier (optional):
'simple' | 'dynamic' | 'advanced'Controls the reference qualifier mode.'simple'— use withreferenceQualfor a plain encoded query (e.g.,'active=true').'advanced'— use withreferenceQualfor ajavascript:scripted qualifier.'dynamic'— use withdynamicRefQualto point to asys_filter_option_dynamicrecord. When omitted, defaults to'simple'. Maps tosys_dictionary.use_reference_qualifier.
-
widget (optional):
stringStyle for the element type such as "radio" -
xmlView (optional):
booleanDisplays the field value as XML -
formula (optional):
stringFormula script for a formula-type virtual field. Sets virtual=true and virtual_type='formula'. Mutually exclusive with dynamicValueDefinitions of type 'calculated_value', which uses virtual_type='script'. -
virtualType (optional):
'script' | 'formula'Specifies the type of virtual/calculated field. Derived automatically: 'formula' when formula is set, 'script' when dynamicValueDefinitions type is 'calculated_value'. Only set explicitly to override.
Warning: Do not use
referenceQualifier(which is only valid onOverrideColumnfor overriding inherited fields). UsereferenceQualfor new column definitions. Using the wrong property name will silently fail — the build succeeds but the condition is not applied.
Usage
import { Table, ReferenceColumn, StringColumn } from '@servicenow/sdk/core';
export default Table({
name: 'x_myapp_request',
label: 'Request',
columns: {
assigned_to: ReferenceColumn({ label: 'Assigned To', referenceTable: 'sys_user' }),
category: ReferenceColumn({
label: 'Category',
referenceTable: 'x_myapp_category',
cascadeRule: 'none',
}),
},
});