SDK 4.2.0 #28
bryce-godfrey
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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
ImportSetFluent APIThe 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
Advanced Configuration with Field Transforms
UiPolicyFluent APIConfigure 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
UI Policy with Scripts
Now.attachAPI for Image FieldsAttach images to
Imagefield type columns.Additional Column Types
The
TableAPI now supports additional database column types:Password2ColumnGuidColumnJsonColumnNameValuePairsColumnUrlColumnEmailColumnHTMLColumnFloatColumnMultiLineTextColumnDurationColumnTimeColumnFieldListColumnSlushBucketColumnTemplateValueColumnApprovalRulesColumnUtility Helper Functions
The SDK now includes helper functions for complex ServiceNow data types, providing strong typing support and simplified syntax.
Duration()Works with the
DurationColumntype for specifying duration values in days, hours, minutes, and seconds.Time()Works with the
TimeColumntype for specifying times in hours, minutes, and seconds.FieldList()Works with the
FieldListColumntype for specifying a list of field names that are type-checked to a specified table, with dot-walking support.TemplateValue()Works with the
TemplateValueColumntype for specifying objects with field-value pairs.Example
TemplateValuein encoded format:cost=100^description=Catalog Item Description^category=Hardware^active=true^EQEnhanced
dependenciesCommandWhen developing ServiceNow applications, having complete type information for instance dependencies outside your app scope is essential for type safety and better developer experience. The
dependenciescommand now provides enhanced support for pulling down type definitions for tables and roles.Configuration
Configure dependencies through the
now.config.jsonfile:{ "dependencies": { "global": { "tables": [ "cmdb_ci_server" ], "roles": [ "admin", "itil" ] } } }Fluent API Type Imports
Fluent code dependencies are now stored in the local
@typesfolder at@types/servicenow/fluentand can be referenced using the#now:{scope}/{category}import alias pattern that is configured through package.json.For existing projects: Manually add the following
importsconfiguration to yourpackage.json(this is automatically configured for new projects):{ "imports": { "#now:*": "./@types/servicenow/fluent/*/index.js" } }Usage example:
Server Script Type Definition Enhancements
Version 4.2 significantly improves type safety for server-side module development. The
@servicenow/glidepackage (v27.0.3+) now includes generic support forGlideRecord,GlideElement, andGlideRecordSecure, enabling proper table-aware type checking.Migration for Existing Projects
To take advantage of enhanced type definitions:
@servicenow/glidepackage:{ "dependencies": { "@servicenow/glide": "27.0.3" } }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 Definitions for Server Scripts Using
Now.includeEnhanced type support for server scripts such as script includes, business rules, and other non-module scripts is now available when using
Now.includeand 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.jstype file extension pattern for any server side code, and.client.jsfor client side javascript.Example:
src/fluent/tsconfig.json{ "files": [], "references": [ { "path": "./tsconfig.server.json" }, { "path": "./tsconfig.client.json" } ] }src/fluent/tsconfig.server.json{ "compilerOptions": { "lib": [ "ES2021" ], "noEmit": true, "checkJs": false, "allowJs": true, "noEmitHelpers": true, "esModuleInterop": false, "module": "None", "types": [] }, "include": [ "./**/*.server.js", "../../@types/servicenow/*.server.d.ts", ] }src/fluent/tsconfig.client.json{ "compilerOptions": { "target": "ES6", "lib": [ "DOM", "ES6" ], "checkJs": false, "allowJs": true, "noEmit": true, "noEmitHelpers": true, "esModuleInterop": false, "module": "None", "types": [] }, "include": [ "./**/*.client.js", "../../@types/servicenow/*.client.d.ts", ] }To get further type checking you can experiment with turning
checkJson in your tsconfig.server.json file to get more diagnostic errors. Script includes that are using olderClass.create()style construction with prototypes will likely produce many errors though, and it is recommended to use ES6 style classes instead to resolve that.🐛 Bug Fixes
ListAPIJSON.stringifyto allow JSON arraysListColumnto allow choicesreferenceTablefield to required forReferenceColumnandListColumnDocumentIdColumnnot populating values for dependent fieldsBusinessRuleNow.IDvalues are usedsys_scopeforsys_atf_steprecords fromATFAPIprocessglobals for BYOF buildsFeedback
For any issues or feedback, please use the SDK discussions: https://github.com/ServiceNow/sdk/discussions
This discussion was created from the release SDK 4.2.0.
Beta Was this translation helpful? Give feedback.
All reactions