Record API - ServiceNow Fluent
- UpdatedJan 30, 2025
- 2 minutes to read
- Washington DC
- ServiceNow SDK
The Washington DC release is no longer supported. As such, the product documentation and release notes are provided for informational purposes only, and will not be updated.
The Record API defines records in any table. Use the Record API to define application metadata that doesn't have a dedicated ServiceNow Fluent API.
Record object
Add data to any table with a record.
| Name | Type | Description |
|---|---|---|
| $id | String or Number | Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. Format: |
| table | String | Required. The name of the table to which the record belongs. |
| data | Object | Fields and their values in the table. For example:To use text content from another file, refer to a file in the application using the Now.include syntax. |
| $meta | Object | Metadata for the application metadata. With the installMethod property, you can map the application metadata to an output directory that loads only in specific
circumstances. Valid values for installMethod:
|
Example
In this example, a record defining a menu category is added to the Menu Category [sys_app_category] table. The menu category style is defined in the css-file.css
file.
import { Record } from "@servicenow/sdk/core";
export const appCategory = Record({
table: 'sys_app_category',
$id: Now.ID[9],
data: {
name: 'example',
style: Now.include('./css-file.css'),
},
})In this example, a record defining a script include is added to the Script Include [sys_script_include] table. The script include uses a script from the SampleClass.server.js file.
import { Record } from "@servicenow/sdk/core";
export const SampleClass = Record({
$id: Now.ID["SampleClass"],
table: "sys_script_include",
data: {
name: "SampleClass",
apiName: "x_sample.SampleClass",
access: "public",
caller_access: "caller_tracking",
protection_policy: "read-only",
script: Now.include("./SampleClass.server.js"),
},
})In this example, a record defining an incident is added to the Incident [incident] table.
import { Record } from '@servicenow/sdk/core';
export const incident1 = Record({
$id: Now.ID['incident-1'],
table: 'incident',
data: {
active: 'true',
approval: 'not requested',
description: 'Unable to send or receive emails.',
incident_state: '1',
short_description: 'Email server is down.',
subcategory: 'email',
caller_id: '77ad8176731313005754660c4cf6a7de',
}
})In this example, a record defining a server is added to the Server [cmdb_ci_server] table.
import { Record } from '@servicenow/sdk/core';
export const ciserver1 = Record({
$id: Now.ID['cmdb-ci-server-1'],
table: 'cmdb_ci_server',
data: {
asset_tag: 'P1000199',
attested: 'false',
can_print: 'false',
company: 'e7c1f3d53790200044e0bfc8bcbe5deb',
cost: '2160',
cost_cc: 'USD',
cpu_speed: '633',
cpu_type: 'GenuineIntel',
disk_space: '100',
manufacturer: 'b7e7d7d8c0a8016900a5d7f291acce5c',
name: 'DatabaseServer1',
os: 'Linux Red Hat',
short_description: 'DB Server',
subcategory: 'Computer',
}
})Related Content
- ServiceNow Fluent
Define application metadata in source code using the ServiceNow Fluent domain-specific programming language.