Skip to content

Releases: ServiceNow/sdk

SDK 4.7.0

21 May 22:42
06adf37

Choose a tag to compare

@servicenow/sdk — Release Notes

Version: 4.7.0
Availability: npm — https://www.npmjs.com/package/@servicenow/sdk


🚀 Overview

Version 4.7.0 adds a universal field override escape hatch, new DataPolicy and protectionPolicy expanded to most APIs, expanded Flow capabilities, and plenty of fixes!


New Fluent APIs

Universal Field Override

Fluent APIs now support an $override property, giving developers an escape hatch to set any field not otherwise exposed by the API surface. This is useful for setting custom properties on APIs from other applications, see the $override doc for more information.

import { BusinessRule } from '@servicenow/sdk/core'

BusinessRule({
  $id: Now.ID['some-id'],
  $override: {
    x_myscope_customfield: 'value',
    u_globalfield: 'value1'
  }
})

Data Policy

The new DataPolicy API enables declarative creation of sys_data_policy2 records, including rule-level conditions and field-level enforcement configuration.

import { DataPolicy } from '@servicenow/sdk/core'

DataPolicy({
    $id: Now.ID['import_soap_policy'],
    table: 'incident',
    shortDescription: 'Data Policy for Import and SOAP',
    description: 'Enforce data validation for records created via import sets or SOAP',
    applyToImportSets: true,
    applyToSOAP: true,
    useAsUiPolicyOnClient: false,
    rules: {
        short_description: {
            mandatory: true,
        },
        caller_id: {
            mandatory: true,
        },
        category: {
            mandatory: true,
        },
    },
})

New Features and Enhancements

Flow

This release significantly expands flow authoring capabilities:

  • Flow Stages — Flows now support stage definitions, with diagnostics and the ability to use stages inside tryCatch blocks.
  • TryCatch — Flows can now define try/catch logic blocks for structured error handling.
  • DoInParallel — A new flow logic block enables parallel execution of steps within a flow.
  • AppendToFlowVariables — A new action appends values to existing flow variable collections.
  • Action Outputs and Error Evaluation — Flows can now evaluate action outputs and error states as part of flow logic.

AI Agent Framework (AIAF)

  • roleList made optional, roleMap added — Both DataAccessConfigType (AiAgent) and DataAccessConfigWorkflowType (AiAgenticWorkflow) now accept either roleList (legacy role sys_ids) or the new roleMap (role names stored in M2M sys_agent_access_role_mapping records). At least one must be non-empty at build time. Customers on ZP10 or later should prefer roleMap.
  • agentDescriptor field added to AiAgent — New optional field ('require_caller_id' | 'created_by_ai_agent_advisor' | 'created_by_build_agent' | '') written to sn_aia_agent_config.

Now Assist Skill Kit (NASK)

  • Adds support for configuring role-based access on NowAssist Skills via two fields (at least one field must be defined):
    • roleMap recommended for ZP10 and AP3+
    • roleRestrictions pre ZP10 and AP3 instances

Table

  • Added augment property. Use this when augmenting an existing table that is not part of the application scope. This can be used when you need to add properties.
  • Added createAccessControls for creating default access controls
  • Added userRole to wire the tables auto-generated access controls to a given user role.

Protection Policy support

  • Added protectionPolicy to all APIs that have sys_policy support in metadata.

CLI Enhancements

  • Transform by table — The transform command now supports targeting one or more specific tables at a time. Records are filtered to the metadata directory on transform, and transformed XML files are cleaned up automatically.
  • Performance - The CLI startup time has been substantially reduced, particularly for commands that don't load the project such as explain, help, version, etc.
  • OAuth client_credentials auth for CI install — The install command now supports OAuth client_credentials flow via environment variables for CI/CD pipeline authentication. New env variables are available to configure this, see ci integration docs.
  • init in current working directory — The init command can now be run directly in the current working directory without requiring a new subdirectory.

Fixes

Flow

  • Fixed datapill becoming empty in script step input for custom action.
  • Fixed an empty annotationType causing a build error after transform.
  • Corrected the lookUpRecord core action property from __snc_dont_fail_on_error to dont_fail_flow_on_error.
  • Fixed a missing action_status element mapping when wfa.errorEvaluation() is present.
  • Fixed internal_name being regenerated from name during Fluent→XML transformation.

Tables

  • Fixed sys_dictionary records not being set to active as part of component output.
  • Fixed calculated and reference field qualifier handling.
  • Fixed callerAccess had incorrect default value
  • Fixed choice on column componentns had incorrect default value

General

  • Fixed the UI Policy plugin dropping sys_ui_policy_action and sys_ui_policy_rl_action records.
  • Fixed Column readOnly and readOnlyOption handling
  • Fluent linting level for server modules is now overridable via new linter property in now.config.json
  • Scope prefix is now validated against the instance vendor code during init command if auth is configured.
  • Improved build times for large projects by reducing garbage collection pressure.
  • Fixed default values for service catalog records.
  • Fixed carriage returns not being escaped, which caused data loss during round-trips on Windows.
  • Fixed transform generating invalid Fluent for ACL, ScriptInclude, and Test records in some situations.
  • Fixed ScheduledScript weekly frequency validation to accept either dayOfWeek or daysOfWeek.

SDK 4.6.1

13 May 16:26
06adf37

Choose a tag to compare

Patch release for @servicenow/sdk

Version: 4.6.1

Fixes:

  • Fix transform generating invalid Fluent for ACL, ScriptInclude, and Test
    • Fix when ScriptInclude has access=package_private and caller_access=2
    • Fix when ACL has local_or_existing = empty string
    • Fix when Test missing second argument in some situations
  • Fix ServiceCatalog not setting correct default values for no_search and ui_type
  • Fix transform for calculated and reference field qualifiers on Table columns
  • Fix active not being set on sys_dictionary outputs by default

New:

  • Add new field augments for Table. Use this when adding new columns to existing tables that do not belong to this app
import { Table, StringColumn } from '@servicenow/sdk/core'

export const incident = Table({
    augments: 'incident',
    schema: {
        x_acme_escalation_reason: StringColumn({
            label: 'Escalation Reason',
            maxLength: 500,
        }),
    },
})

SDK 4.6.0

15 Apr 21:57

Choose a tag to compare

@servicenow/sdk — Release Notes

Version: 4.6.0
Availability: npm — https://www.npmjs.com/package/@servicenow/sdk


🚀 Overview

Version 4.6.0 adds several new Fluent APIs, Custom Action support, improvements to AIAF and NASK, and a range of bug fixes.

Note

✨ New: ServiceNow SDK AI Skills

Build, edit, and deploy Fluent applications using external AI coding assistants like Claude Code or Kiro — outside the ServiceNow IDE. The now-sdk-explain skill (powered by the explain command in this release) gives your AI assistant real-time access to live SDK documentation, so it always works from current API signatures and platform patterns rather than outdated training data.

Requires @servicenow/sdk v4.6.0 or newer. Learn more →

New Fluent APIs

Custom Actions & Flow Enhancements

This release significantly expands Flow and Subflow authoring capabilities:

  • Author Custom Actions — Custom Action definitions can now be created directly in Fluent with typed step references for IntelliSense and compile-time safety. Script steps are externalized to separate files for a better editing experience.
  • Call Subflows from Flows and Subflows — Flows and Subflows can now invoke other Subflows as steps.
  • Call Custom Actions from Flows and Subflows — Custom Actions can be used as steps within Flows and Subflows.
  • Reference global and cross-scope Subflows and Actions — Flows and Subflows can reference Subflows and Custom Actions from global scope or other application scopes via the SDK's dependency mechanism.

Inbound Email Actions

The new InboundEmailAction API enables declarative creation of inbound email action records (sysevent_in_email_action).

Service Portal

Additional Service Portal APIs have been added to round out existing coverage:

  • SPHeaderFooter for creating header and footer records
  • SPPageRouteMap for defining page-to-page redirect mappings within a portal

Form

The Form API is now available, enabling declarative configuration of forms directly in Fluent.

Updates to Existing APIs

AI Agent Framework (AIAF)

Automatic ACL Generation for AI Agents

AiAgent and AiAgenticWorkflow APIs now automatically generate the required security ACL records as part of the build. Developers no longer need to define ACLs separately for their agents.

Now Assist Skill Kit (NASK)

Auto-generated Standard Outputs

When the outputs array is omitted from a NowAssistSkillConfig, the five standard skill outputs (response, provider, errorcode, status, error) are now automatically generated. Only define outputs when adding custom outputs beyond these defaults.

Expanded Input Data Types

Skill input attributes now support additional data types: glide_record, simple_array, json_object, and json_array — in addition to the existing string, numeric, and boolean types. A tableName is required when using glide_record, and an optional truncate flag is available for scalar types.

New Features & Changes

Stricter sys_id Conflict Detection

The build now distinguishes between two types of sys_id conflicts:

  • Fluent vs Fluent conflicts (two .now.ts files defining the same record) always produce an error.
  • XML vs Fluent conflicts continue to respect the --errorOnConflict flag.

explain Command Improvements

The now-sdk explain command has been significantly improved:

  • More accurate results using tag-based lookup.
  • --list displays the full index of available topics.
  • --format=raw outputs raw Markdown.
  • --peek shows a brief summary without opening the full document.
# Browse all available topics
now-sdk explain records --list

# Preview a topic without opening the full doc
now-sdk explain records --peek

Other Changes

  • The Table API now supports creating dictionary override records (sys_dictionary_override) directly, without needing a separate API.
  • ScheduledScript script fields now support modules.
  • Project templates have been simplified: tsconfig relocated to src/, unnecessary index file removed, and a jsconfig added for JavaScript templates.

Bug Fixes

Now Assist Skill Kit (NASK)

  • Fixed duplicate tool inputs and outputs being generated in certain configurations.
  • Fixed issues with UI action handling in skill definitions.
  • Fixed delete functionality for skill records.
  • Fixed active flag not being correctly applied during build.

Service Portal

  • Fixed duplicate M2M records being created for catalog and knowledge base items when using the Service Portal Fluent API.
  • Fixed missing portal settings and availability config fields on CatalogItemRecordProducer that were already supported on CatalogItem (hideAddToCart, hideAddToWishList, hideDeliveryTime, hideQuantitySelector, hideSP, image, model, mobilePictureType).

Front-end Framework Support

  • Fixed source manifest generation failing when a project contains multiple UI pages with different entry file names.
  • Fixed source artifacts missing assets that were imported via CSS url() references.

Flows & Custom Actions

  • Fixed a regression where flow variable column types were lost during build.
  • Fixed a data type mismatch in datapill expressions where reference types were incorrectly treated as strings.
  • Fixed empty strings being silently accepted for mandatory inputs in core actions.

Transform

  • Fixed HTML entities being appended as individual characters instead of being decoded during transform.
  • Fixed a TypeScript error after transform where "GUID" was not recognized as a valid flow data type.

Build

  • Fixed UI Page build failures when inline scripts contain unescaped < operators or HTML literals.
  • Fixed object keys that start with a digit not being quoted, which caused JavaScript parse errors.

Configuration

  • tableDefaultLanguage in now.config has been renamed to defaultLanguage. The old name continues to work but is deprecated.

Fluent Language Extension v2.1.2VS Code Marketplace · Open VSX

SDK 4.5.0

30 Mar 16:26

Choose a tag to compare

@servicenow/sdk — Release Notes

Version: 4.5.0
Availability: npm — https://www.npmjs.com/package/@servicenow/sdk


🚀 Overview

Version 4.5.0 adds new Fluent APIs and fixes some more bugs!

New Fluent APIs

Instance Scan Records

New APIs are available for configuring Instance Scan checks for detecing anomalies on your instance.

Scheduled Script

The ScheduledScript (sysauto_script) API can be used to execute custom scripst at specified times or on a recurring basis.

ServicePortal

More APIs have been added for creating Service Portal items to round out the existing Fluent APIs that already exist.

Now Assist Skill Kit

Adds a Fluent API NowAssistSkillConfig for creating NowAssist Skill configurations

AI Agent Studio

The addition of Fluent AI Agent Studio Fluent APIs enable the create and manage AI agents and workflows!

  • Adds new Fluent APIs AiAgent for creating AI Agent definitions
  • Adds new Fluent API AiAgentWorkflow that allows for creating dynamic agentic workflow definitions

New Features

Flows

  • All Flows and Subflows installed from the SDK will now be auto published as part of now-sdk install. Use flag -skip-flow-activation to disable this if needed.
  • NOTE: This requires version 4.1.1 or later of the ServiceNow IDE installed on your instance.

Changes

  • Removed eslint dependency from projects and updated internal reference to v9. After upgrading to 4.5.0 of @servicenow/sdk you can remove the dependency on @servicenow/eslint-plugin-sdk-app-plugin from your projects package.json
  • init command no longer prompts for credentials unless converting from the instance
  • Fix metadata folder content copy for binary files being copied as utf8
  • FieldListColumn accepts either dependent or attributes.table
  • Fix EmailNotification not correctly escaping encoded values
  • Fix CatalogItem checkbox selection required field mapping missing
  • Fix dev server watching HTML and CSS asset files
  • Fix unable to create global app with UI customizations
  • Flow fixes:
    • setFlowVariable transform issues
    • SubFlow complex object transform issues
    • Trigger createOrUpdate converting to wrong type on transform
    • Flow runAs defaulting to user instead of system
    • Issues with diagnostic errors on setFlowVariables not working

SDK 4.4.0

12 Mar 00:48

Choose a tag to compare

@servicenow/sdk — Release Notes

Version: 4.4.0
Availability: npm — https://www.npmjs.com/package/@servicenow/sdk


🚀 Overview

Version 4.4.0 fixes some bugs and adds a new dev server capability for front end UI building with the SDK, and some internal support for future version of Build Agent and Australia release for global app support!


New Features

Front-End Dev Server

A highly requested feature — the dev server drastically reduces build cycles and enables rapid UI development without needing to deploy to an instance. Requests are proxied to the ServiceNow instance defined in your auth credentials.

Note: Dev server scripts are included in new projects only. A future release will add a command to install it into existing projects.

Getting started:

  1. Run sdk init using the react or vue template
  2. Start the server with npm run dev

Requirements:

  • @servicenow/isomorphic-rollup >= 1.2.14
  • @servicenow/sdk >= 4.4.0
  • now.dev.mjs present in your project (generated during init)

ServiceCatalog & Flows

Add support between Flows and ServiceCatalog in Fluent for interacting with catalog variables and actions in Flows, and for Catalog Items to trigger Flows!

  • Support for Flow Service Catalog Item triggers
  • Support for getCatalogVariables action in Flows
  • Support for `createCatalogTask' action in Flows
  • Support for submitCatalogItemRequest action in Flows

See sdk-examples Flow samples

Changes

  • Fix invalid transformation for duration field for Sla
  • Fix requestMethod on CatalogItem and CatalogItemProducer not serializing properly
  • Stable UX asset IDs (will see keys.ts location changes)
  • Add protectionPolicy to ACL
  • Add tableDefaultLanguage to now.config.json to support setting language on table column labels
  • Fix APIs that were not restricting arbitrary properties!

NOTE: Many APIs were not strictly enforcing that extra properties could not be defined on the API, which caused some usage errors around mispelling properties or thinking they can add a property and it will be added to the build output, and should be fixed or removed.

For example this would not produce an error:

Property({
 $id: Now.ID['property-1'],
 name: 'x_foo.myproperty',
 randomProperty: true
})

This will now produce an error diagnostic that randomProperty does not exist as an option on Property! This may introduce a build error for existing projects when upgrading to 4.4.0, but these properties were being ignored during build causing false positives.

SDK 4.3.0

25 Feb 22:11

Choose a tag to compare

@servicenow/sdk — Release Notes

Version: 4.3.0
Availability: npm — https://www.npmjs.com/package/@servicenow/sdk


🚀 Overview

Version 4.3.0 introduces the highly anticipated Flow API, significant build and transform performance improvements, expanded Service Catalog support, and several new platform capabilities.

This release focuses on enabling workflow-as-code, improving developer productivity, and strengthening type safety across UI and automation development.


🎊 New Fluent APIs

Flow API (MVP)

The Flow API enables building ServiceNow workflows entirely in code using Fluent. Please try this out if you are a Flow user, and give us feedback in the discussions area, we plan to keep enhancing Flows in the next few releases!

Benefits include:

  • Workflow-as-code
  • AI-assisted development
  • Pull request reviews
  • Standardized development workflows

Supported Capabilities

Flow Definition

  • Name, description, runAs
  • Flow priority and protection
  • Typed flow variables

Triggers

  • Record: created, updated, createdOrUpdated
  • Scheduled: daily, weekly, monthly, repeat, runOnce
  • Application: inboundEmail, remoteTableQuery, knowledgeManagement, slaTask

Actions

  • Record CRUD operations
  • Communication (email, SMS, notifications, approvals)
  • Attachment management
  • Email utilities
  • Core utilities and task automation

Flow Logic

  • Conditional branching (if, elseIf, else)
  • Loops (forEach, exitLoop, skipIteration)
  • Variable management
  • Flow control and delays

Data & Types

  • wfa.dataPill() data referencing
  • Full TypeScript type safety
  • Reference dot-walking support

MVP Limitations

The following capabilities are planned for future releases:

  • ❌ Subflow invocation
  • ❌ Try/Catch error handling
  • ❌ Step rewind (Go-Back-To)
  • ❌ Service Catalog trigger
  • ❌ Catalog actions
  • ❌ DateTime flow variables (use StringColumn workaround)

Example

An incident severity alert flow — triggers on incident creation, branches by severity, notifies stakeholders, and sets state to In Progress.

import { action, Flow, wfa, trigger } from '@servicenow/sdk/automation'

export const incidentSeverityAlertFlow = Flow(
    {
        $id: Now.ID['incident_severity_alert_flow'],
        name: 'Incident Severity Alert Flow',
        description: 'Notifies team based on incident severity and sets state to In Progress',
    },
    wfa.trigger(
        trigger.record.created,
        { $id: Now.ID['incident_created_trigger'] },
        { table: 'incident', condition: 'origin=NULL', run_flow_in: 'background' }
    ),
    (params) => {
        // Log the new incident
        wfa.action(
            action.core.log,
            { $id: Now.ID['log_incident'] },
            {
                log_level: 'info',
                log_message: `New incident: ${wfa.dataPill(params.trigger.current.short_description, 'string')}`,
            }
        )

        // High severity — notify manager + SMS all assignees
        wfa.flowLogic.if(
            {
                $id: Now.ID['check_high'],
                condition: `${wfa.dataPill(params.trigger.current.severity, 'string')}=1`,
            },
            () => {
                wfa.action(
                    action.core.sendNotification,
                    { $id: Now.ID['notify_manager'] },
                    {
                        table_name: 'incident',
                        record: wfa.dataPill(params.trigger.current.sys_id, 'reference'),
                        notification: 'high_severity_manager_notification',
                    }
                )

                wfa.flowLogic.forEach(
                    wfa.dataPill(params.trigger.current.additional_assignee_list, 'array.string'),
                    { $id: Now.ID['foreach_assignees'] },
                    () => {
                        wfa.action(
                            action.core.sendSms,
                            { $id: Now.ID['sms_assignee'] },
                            {
                                recipients: wfa.dataPill(params.trigger.current.additional_assignee_list, 'array.string'),
                                message: `High severity: ${wfa.dataPill(params.trigger.current.short_description, 'string')}`,
                            }
                        )
                    }
                )
            }
        )

        // Medium severity — SMS assignees only
        wfa.flowLogic.elseIf(
            {
                $id: Now.ID['check_medium'],
                condition: `${wfa.dataPill(params.trigger.current.severity, 'string')}=2`,
            },
            () => {
                wfa.flowLogic.forEach(
                    wfa.dataPill(params.trigger.current.additional_assignee_list, 'array.string'),
                    { $id: Now.ID['foreach_assignees_medium'] },
                    () => {
                        wfa.action(
                            action.core.sendSms,
                            { $id: Now.ID['sms_assignee_medium'] },
                            {
                                recipients: wfa.dataPill(params.trigger.current.additional_assignee_list, 'array.string'),
                                message: `Medium severity: ${wfa.dataPill(params.trigger.current.short_description, 'string')}`,
                            }
                        )
                    }
                )
            }
        )

        // Always set state to In Progress
        wfa.action(
            action.core.updateRecord,
            { $id: Now.ID['update_state'] },
            {
                table_name: 'incident',
                record: wfa.dataPill(params.trigger.current.sys_id, 'reference'),
                values: TemplateValue({ state: '2' }),
            }
        )
    }
)

🧾 Service Catalog Enhancements

Added support for Service Catalog and supporting entities:

  • Catalog Client Scripts (catalog_script_client)
  • Catalog Items (sc_cat_item)
  • Catalog UI Policies (catalog_ui_policy)
  • Catalog Variables (item_option_new)
  • Variable Sets (item_option_new_set)
  • Record Producers (sc_cat_item_producer)

Catalog Variables

Fluent provides 31 different types of catalog variables to support a wide range of form input needs. Each variable type has a specific function that creates a properly configured variable object.

Example

CatalogItem({
    $id: Now.ID['basic_catalog_item'],
    name: 'Basic Laptop Request',
    shortDescription: 'Request a standard laptop for business use',
    description: 'Use this form to request a standard laptop for business use. Approval from your manager is required.',
    catalogs: [catalogServiceCatalog],
    categories: [categoryHardware],
    variableSets: [{ variableSet: userInfoVarSet, order: 100 }],
    executionPlan: '523da512c611228900811a37c97c2014',
})

CatalogClientScript({
    $id: Now.ID['new-laptop-client-script'],
    name: 'Required By Date Validation',
    script: `function onSubmit() {
    var reqDate = g_form.getValue('required_by_date');
    var today = new Date();
    var selectedDate = new Date(reqDate);
    var diffDays = (selectedDate - today) / (1000 * 60 * 60 * 24);
    if (diffDays < 7) {
        alert('Required By date must be at least 7 days from today.');
        return false;
    }
    return true;
}
`,
    type: 'onSubmit',
    catalogItem: requestNewLaptop,
    appliesOnRequestedItems: true,
    appliesOnCatalogTasks: true,
    appliesOnTargetRecord: true,
    vaSupported: true,
})

VariableSet({
    $id: 'contact_info_set',
    title: 'Contact Information',
    internalName: 'contact_information',
    description: 'Standard contact information fields including phone, email, and address',
    type: 'singleRow',
    order: 100,
})

CatalogUIPolicy({
  $id: Now.ID['employee_request_ui_policy_external_1'],
  shortDescription: 'If urgent is true, require manager approval and show department',
  catalogCondition: `${departmentVariableSet.variables.urgent} === true`,
  variableSet: departmentVariableSet,
  appliesTo: 'set',
  actions: [
    {
      variableName: departmentVariableSet.variables.department,
      order: 100,
      mandatory: true,
      visible: true,
    }
  ],
});

CatalogItemRecordProducer({
    $id: Now.ID['basic_incident_producer'],
    name: 'Report an Incident',
    shortDescription: 'Create a new incident ticket',
    description: '<p>Use this form to report IT issues and incidents.</p>',
    table: 'incident',
    catalogs: [catalogServiceCatalog],
    categories: [categoryIncidents],
    variableSets: [
        { variableSet: incidentDetailsVarSet, order: 100 },
    ],
    hideSaveAsDraft: false,
    mandatoryAttachment: false,
    hideAttachment: true,
    availableFor: [userCriteriaITStaff],
})

Email Notification

Creates an Email Notification (sysevent_email_action) in ServiceNow.

import { EmailNotification } from '@servicenow/sdk/core'

EmailNotification({
    table: 'incident',
    name: 'Incident Assigned Notification',
    description: 'Notification sent when an incident is assigned',
    triggerConditions: {
        generationType: 'engine',
        onRecordInsert: true,
        onRecordUpdate: true,
        condition: 'assigned_toISNOTEMPTY'
    },
    recipientDetails: {
        recipientFields: ['assigned_to'],
        sendToCreator: false
    },
    emailContent: {
        contentType: 'text/html',
        subject: 'Incident ${number} assigned to you',
        messageHtml: '<p>You have been assigned incident ${numb...
Read more

SDK 4.2.0

21 Jan 06:15

Choose a tag to compare

Available on npm at @servicenow/sdk

What's New in v4.2

Version 4.2 introduces powerful new Fluent APIs, enhanced type safety for server-side development, and improved developer tooling. This release focuses on making ServiceNow application development more intuitive and type-safe.

🚀 New Features

ImportSet Fluent API

The ImportSet API provides a fluent interface for creating Transform Maps with their associated field mappings (sys_transform_entry) and transform scripts (sys_transform_script).

Note: Data Sources (sys_data_source) should be configured through the Record API, as they contain structurally flat, independent metadata.

Basic Configuration

ImportSet({
    $id: Now.ID['user-import-set'],
    name: 'User Data Import',
    targetTable: 'sys_user',
    sourceTable: 'u_user_import_staging',
    active: true,
    runBusinessRules: true,
    enforceMandatoryFields: 'onlyMappedFields',
    fields: {
        first_name: 'name',
        last_name: 'last_name',
        email: { 
            sourceField: 'email', 
            coalesce: true, 
            coalesceCaseSensitive: false 
        }
    }
})

Advanced Configuration with Field Transforms

ImportSet({
    $id: Now.ID['advanced-import-set'],
    name: 'Advanced User Import',
    targetTable: 'sys_user',
    sourceTable: 'u_user_import_staging',
    active: true,
    runScript: true,
    script: transformUserData, // Imported function
    fields: {
        email: {
            sourceField: 'email_address',
            coalesce: true,
            useSourceScript: true,
            sourceScript: `answer = (function transformEntry(source) {
                return source.email_address.toLowerCase().trim();
            })(source);`
        },
        department: {
            sourceField: 'dept_code',
            choiceAction: 'create'
        }
    },
    scripts: [
        {
            active: true,
            order: 100,
            when: 'onBefore',
            script: `(function runTransformScript(source, map, log, target) {
                if (!source.email_address || source.email_address.indexOf('@') === -1) {
                    log.error('Invalid email address: ' + source.email_address);
                    return;
                }
            })(source, map, log, target);`
        }
    ]
})

UiPolicy Fluent API

Configure UI Policy records (sys_ui_policy) with their associated UI Policy Actions (sys_ui_policy_action) and Related List Actions (sys_ui_policy_rl_action) to control field visibility, mandatory status, read-only behavior, and related list visibility on forms.

Basic UI Policy

UiPolicy({
    $id: Now.ID['incident_related_list_control'],
    table: 'incident',
    shortDescription: 'Control related lists for high priority incidents',
    onLoad: true,
    conditions: 'priority=1',
    actions: [
        {
            field: 'urgency',
            mandatory: true
        }
    ],
    relatedListActions: [
        {
            $id: Now.ID['rl_action_1'],
            list: 'b9edf0ca0a0a0b010035de2d6b579a03', // System relationship (GUID)
            visible: false
        },
        {
            $id: Now.ID['rl_action_2'],
            list: 'incident.caller_id', // table.field format (reference field)
            visible: true
        },
        {
            $id: Now.ID['rl_action_3'],
            list: 'change_request.change_task', // Parent-child relationship
            visible: 'ignore'
        }
    ]
})

UI Policy with Scripts

UiPolicy({
    $id: Now.ID['task_assignment_policy'],
    table: 'task',
    shortDescription: 'Task assignment validation with scripts',
    onLoad: true,
    conditions: 'assigned_to=',
    runScripts: true,
    scriptTrue: `function onCondition() {
        g_form.addInfoMessage('Please assign this task to a user.');
        g_form.setMandatory('assigned_to', true);
    }`,
    scriptFalse: `function onCondition() {
        g_form.clearMessages();
    }`,
    uiType: 'desktop',
    isolateScript: true,
    actions: [
        {
            field: 'assigned_to',
            mandatory: true
        }
    ]
})

Now.attach API for Image Fields

Attach images to Image field type columns.

import { Record } from '@servicenow/sdk/core'

Record({
    $id: Now.ID['test'],
    table: 'sp_portal',
    data: {
        title: 'Test Portal',
        url_suffix: 'test',
        icon: Now.attach('../../assets/servicenow.jpg')
    }
})

Additional Column Types

The Table API now supports additional database column types:

  • Password2Column
  • GuidColumn
  • JsonColumn
  • NameValuePairsColumn
  • UrlColumn
  • EmailColumn
  • HTMLColumn
  • FloatColumn
  • MultiLineTextColumn
  • DurationColumn
  • TimeColumn
  • FieldListColumn
  • SlushBucketColumn
  • TemplateValueColumn
  • ApprovalRulesColumn

Utility Helper Functions

The SDK now includes helper functions for complex ServiceNow data types, providing strong typing support and simplified syntax.

Duration()

Works with the DurationColumn type for specifying duration values in days, hours, minutes, and seconds.

Record({
    table: 'u_my_table',
    data: {
        duration_field: Duration({ days: 1, hours: 6, minutes: 30, seconds: 15 })
    }
})

Time()

Works with the TimeColumn type for specifying times in hours, minutes, and seconds.

Record({
    table: 'u_my_table',
    data: {
        time_field: Time({ hours: 6, minutes: 30, seconds: 15 }), // Basic example
        time_tz_field: Time({ hours: 6, minutes: 30, seconds: 15 }, 'America/New_York') // With timezone
    }
})

FieldList()

Works with the FieldListColumn type for specifying a list of field names that are type-checked to a specified table, with dot-walking support.

Record({
    table: 'u_my_table',
    data: {
        field_list_field: FieldList<'sys_user'>(['name', 'company', 'active', 'manager.name'])
    }
})

TemplateValue()

Works with the TemplateValueColumn type for specifying objects with field-value pairs.

Example TemplateValue in encoded format: cost=100^description=Catalog Item Description^category=Hardware^active=true^EQ

Record({
    table: 'u_my_table',
    data: {
        template_field: TemplateValue({
            cost: 100,
            description: 'Catalog Item Description',
            category: 'Hardware',
            active: true,
        })
    }
})

Enhanced dependencies Command

When developing ServiceNow applications, having complete type information for instance dependencies outside your app scope is essential for type safety and better developer experience. The dependencies command now provides enhanced support for pulling down type definitions for tables and roles.

Configuration

Configure dependencies through the now.config.json file:

{
  "dependencies": {
    "global": {
      "tables": [
        "cmdb_ci_server"
      ],
      "roles": [
        "admin",
        "itil"
      ]
    }
  }
}

Fluent API Type Imports

Fluent code dependencies are now stored in the local @types folder at @types/servicenow/fluent and can be referenced using the #now:{scope}/{category} import alias pattern that is configured through package.json.

For existing projects: Manually add the following imports configuration to your package.json (this is automatically configured for new projects):

{
  "imports": {
    "#now:*": "./@types/servicenow/fluent/*/index.js"
  }
}

Usage example:

import { Acl } from "@servicenow/sdk/core";
import { role as globalRole } from "#now:global/security";

Acl({
    $id: Now.ID["my_acl"],
    type: "record",
    table: "incident",
    operation: "read",
    roles: [globalRole.admin, globalRole.itil],
});

Server Script Type Definition Enhancements

Version 4.2 significantly improves type safety for server-side module development. The @servicenow/glide package (v27.0.3+) now includes generic support for GlideRecord, GlideElement, and GlideRecordSecure, enabling proper table-aware type checking.

Migration for Existing Projects

To take advantage of enhanced type definitions:

  1. Update the @servicenow/glide package:
   {
     "dependencies": {
       "@servicenow/glide": "27.0.3"
     }
   }
  1. Run the dependencies command:
   now-sdk dependencies
  1. Update src/server/tsconfig.json:
   {
     "include": [
       "../../@types/**/*.modules.d.ts"
     ]
   }

Result

Module files now provide rich type information for GlideRecord calls for any table on your instance:

Type-aware GlideRecord autocomplete

Type Definitions for Server Scripts Using Now.include

Enhanced type support for server scripts such as script includes, business rules, and other non-module scripts is now available when using Now.include and can take advantage of the type definitions if the @types folder as well. To connect these Typescript definitions to your code, we suggest using a .server.js type file extension pattern for any server side code, and .client.js for client side javascript.

Examp...

Read more

SDK 4.1.1

10 Dec 20:06

Choose a tag to compare

Available on npm at @servicenow/sdk

This is a minor patch release to fix some issues with module dependencies, and address some dependency vulnerabilities

Fixes:

  • Support third party modules that are imported using trailing slashes Ex. require('buffer/') which are now supported in glide
  • Support for declaring a dependency on libraries that are named the same as node_builtins in order to use those libraries on the platform
  • Fix critical and high severity vulnerabilities in some 3rd party dependencies

SDK 4.1.0

25 Nov 20:10

Choose a tag to compare

Availalbe on npm at @servicenow/sdk

🚀 New Features

Module Include/Exclude File Patterns

  • Added support for specifying include and exclude file patterns during module builds.

  • Useful for omitting test files or other support files from being treated as module files.

  • New now.config.json properties:

    • serverModulesIncludePatterns
    • serverModulesExcludePatterns

Default patterns:

// Include defaults
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
"**/*.cts",
"**/*.cjs",
"**/*.mts",
"**/*.mjs",
"**/*.json"

// Exclude defaults
"**/*.test.ts",
"**/*.test.js",
"**/*.d.ts"

Apply Templates to Existing Projects

  • Running init inside an existing SDK project now prompts for template selection.
  • Enables applying UI templates and others to already initialized projects.

Script Include Type Generation for Modules

  • The dependencies command now scans modules for scope definitions and fetches script-include types from the instance.
  • Types are saved under @types/servicenow.
  • Detection is based on subpath imports under the @servicenow/glide namespace like @servicenow/glide/[scope].

Example:

import { global } from "@servicenow/glide/global";

function test() {
  const utils = new global.UtilScript();
  const tables = utils.getTables("cmdb_ci_server");
}

🐛 Fixes

  • Fixed List records not being deleted on build when fluent code is removed.
  • Ignored type-only imports in sys modules during dependency generation.
  • Fixed UiAction onClick property being cleared on the instance.
  • Added diagnostics for missing .html file imports.
  • Ensured $meta.installMethod is respected on child records during build.
  • Fixed lstat errors when using certain 3rd-party front-end dependencies (e.g., @mix/x-charts).
  • Corrected ATF Test sys_scope not being set properly during build.
  • Fixed radio column choices not being populated during transform.
  • Corrected ClientScript diagnostic errors for type = 'onChange' | 'onLoad' when field is set.
  • Fixed multiple transform issues with UiPolicy.
  • Fixed build failures when fluent content includes XML CDATA escape sequences (]]>).
  • Ensured priority is captured correctly during BusinessRule transform.

SDK 4.0.2

29 Sep 22:55

Choose a tag to compare

This is a patch release for @ServiceNow/sdk version 4.0.2

  • Fix an issue with the front end framework development build system on the ServiceNow IDE