ServiceNow Fluent

  • Release version: Yokohama
  • Updated March 12, 2026
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of ServiceNow Fluent

    ServiceNow Fluent is a declarative, domain-specific language (DSL) based on TypeScript designed for defining application metadata in source code within the ServiceNow platform. It replaces manual metadata configuration through UI forms or builder tools by allowing developers to define tables, roles, ACLs, business rules, and Automated Test Framework tests programmatically. This approach streamlines application creation and modification using the ServiceNow IDE or SDK.

    Show full answer Show less

    ServiceNow Fluent supports two-way synchronization, enabling seamless updates between source code and metadata across the ServiceNow instance. This ensures that changes made in code or through the platform’s UI remain consistent and synchronized.

    Key Features

    • Domain-Specific Language: Uses TypeScript to declaratively define application metadata files (sysmetadata).
    • Extensive API Support: Provides APIs for common metadata types and a Record API for less common metadata, facilitating comprehensive metadata management in code.
    • Two-Way Sync: Automatically syncs changes between source code and ServiceNow metadata, preserving consistency.
    • Integration with ServiceNow IDE and SDK: Fully supported in modern development tools, allowing a streamlined developer experience.
    • Selective Sync Control: Supports directives to ignore diagnostics or disable syncing at line, object, or file levels, providing flexibility during development.
    • Code Modularization: Supports importing server-side scripts and JavaScript modules to reuse logic within business rules and client scripts.
    • Limitations: Certain metadata types, such as Metadata Snapshots and UX Assets, are not supported as Fluent code and remain as XML files.

    Usage and Practical Application

    Developers write metadata definitions in files with a .now.ts extension using ServiceNow Fluent APIs. For example, tables, client scripts, and business rules can be defined concisely in code, referencing external JavaScript modules for scripting logic. This approach enables:

    • Rapid creation and modification of application components through source code.
    • Clear version control and code review processes for metadata changes.
    • Automated generation of platform metadata files from source code, reducing manual errors.

    The example provided demonstrates defining a custom table with columns, a client script that displays a message on record load, and a business rule that logs state changes. This underscores how Fluent centralizes application logic and metadata in a manageable, code-centric format.

    Getting Started and Further Resources

    To leverage ServiceNow Fluent, customers should use the ServiceNow IDE or SDK, where Fluent is fully supported. Refer to the ServiceNow Fluent API reference and SDK examples repository on GitHub for the latest supported metadata types and coding examples. This ensures best practices and up-to-date usage guidance.

    Define application metadata in source code using the ServiceNow Fluent domain-specific programming language.

    Overview of ServiceNow Fluent

    ServiceNow Fluent is a declarative, domain-specific language (DSL) based on TypeScript for defining the metadata files [sys_metadata] that make up applications and includes APIs for the different types of metadata, such as tables, roles, ACLs, business rules, and Automated Test Framework tests.

    Developers define this metadata in a few lines of code instead of through a form or builder tool user interface. Applications created or converted with the ServiceNow IDE or ServiceNow SDK support development in ServiceNow Fluent.

    ServiceNow Fluent supports two-way synchronization, which allows changes to metadata to be synced from other ServiceNow AI Platform user interfaces into source code and changes to source code to be synced back to metadata across the instance.

    To get started using the ServiceNow IDE or ServiceNow SDK, see the ServiceNow IDE or ServiceNow SDK documentation.

    ServiceNow Fluent APIs

    ServiceNow Fluent includes APIs for many types of metadata. You can use the Record API to define application metadata that doesn't have a dedicated API. For the latest list of supported APIs and examples, see the ServiceNow Fluent API reference and ServiceNow SDK examples repository on GitHub.

    Note:
    A limited number of metadata types, such as Metadata Snapshots [sys_metadata_link] and UX Assets [sys_ux_lib_asset], can't be represented as ServiceNow Fluent code and aren't transformed. These metadata types remain as metadata XML files in the metadata directory of your application.

    ServiceNow Fluent usage

    In files with the .now.ts extension, use objects in the ServiceNow Fluent APIs to define metadata in the application. You must also include the required imports for the APIs from @servicenow/sdk/core. For objects with server-side scripts, such as the BusinessRule object, you can import and use code from JavaScript modules.

    The following example includes the definitions of a table, client script, and business rule in the application. The client script uses a script from the client-script.js file. The business rule uses a function from the script.js JavaScript module.
    import '@servicenow/sdk/global'
    import { BusinessRule, ClientScript, DateColumn, StringColumn, Table } from '@servicenow/sdk/core'
    import { showStateUpdate } from '../server/script.js'
    
    //creates todo table, with three columns (deadline, status and task)
    export const x_snc_example_to_do = Table({
        name: 'x_snc_example_to_do',
        schema: {
            deadline: DateColumn({ label: 'Deadline' }),
            state: StringColumn({
                label: 'State',
                choices: {
                    ready: { label: 'Ready' },
                    completed: { label: 'Completed' },
                    inProgress: { label: 'In Progress' },
                },
            }),
            task: StringColumn({ label: 'Task', maxLength: 120 }),
        },
    })
    
    //creates a client script that pops up 'Table loaded successfully!!' message everytime todo record is loaded
    ClientScript({
        $id: Now.ID['cs0'],
        name: 'my_client_script',
        table: 'x_snc_example_to_do',
        active: true,
        appliesExtended: false,
        global: true,
        uiType: 'all',
        description: 'Custom client script generated by Now SDK',
        isolateScript: false,
        type: 'onLoad',
        script: Now.include('../client/client-script.js'),
    })
    
    //creates a business rule that pops up state change message whenever a todo record is updated
    BusinessRule({
        $id: Now.ID['br0'],
        action: ['update'],
        table: 'x_snc_example_to_do',
        script: showStateUpdate,
        name: 'LogStateChange',
        order: 100,
        when: 'after',
        active: true,
    })
    The client script referenced from the ClientScript object:
    function onLoad() {
        g_form.addInfoMessage("Table loaded successfully!!")
    }
    The JavaScript module referenced from the BusinessRule object:
    import { gs } from '@servicenow/glide'
    
    export function showStateUpdate(current, previous) { 
        const currentState = current.getValue('state')
        const previousState = previous.getValue('state')
    
        gs.addInfoMessage(`state updated from "${previousState}" to "${currentState}"`)
    }

    After building the application, this source code generates the following application metadata files on the instance.

    Figure 1. Application metadata generated from ServiceNow Fluent code
    Application files generated from the example code.
    Tip:
    You can use the following directives in a code comment to help manage your code:
    • @fluent-ignore: Suppresses ServiceNow Fluent diagnostic warnings and errors in the following line of code.
    • @fluent-disable-sync: Turns off syncing changes to a ServiceNow Fluent object. Use before a call expression (for example, Record({ ... })) to turn off syncing for that object and its child objects. Only use this directive if you want to ignore changes made outside of the source code to the object and never update it when syncing.
    • @fluent-disable-sync-for-file: Turns off syncing changes to a ServiceNow Fluent file (.now.ts). Use in the first line of the file to turn off syncing for all code in the file. Only use this directive if you want to ignore changes made outside of the source code to the file and never update it when syncing.