Create and develop custom applications in source code using familiar development tools and processes.

Overview of developing in source code

You can create scoped applications in code using the ServiceNow IDE on the Now Platform or locally in Visual Studio Code Desktop with the ServiceNow SDK.

In either development environment, you use ServiceNow Fluent, a domain-specific programming language, to define the metadata that makes up applications. ServiceNow Fluent includes APIs for defining the different types of metadata.

With the ServiceNow IDE or ServiceNow SDK, you can also create JavaScript modules and use third-party libraries in your application to optimize code reuse in scripts within a scoped application.

Developing and maintaining applications in source code enables you to work in familiar development environments, create and modify complex applications, manage code in source control more easily, and catch errors at build time.

Comparison of the ServiceNow IDE and the ServiceNow SDK

Application structure

Custom scoped applications created with the ServiceNow IDE or ServiceNow SDK include source code files and metadata XML files. The package.json and now.config.json files define the application structure, which is similar to that of Node.js applications or Node Package Manager (npm) packages.

Figure 1. Default structure of an application created in the ServiceNow IDE
Structure of an application created in the ServiceNow IDE

By default, applications include the following directories and files. You can modify certain aspects of the application structure to suit your needs in the now.config.json file.

.now
Directory containing caching and metric information for the build and install processes.
dist/app
Directory containing the build artifacts for packaging.
metadata

Directory containing the application metadata (XML) of the application, such as table schemas and business rules, organized in the same directory structure as existing ServiceNow applications.

Note: Application metadata shouldn't be edited from the XML files. Edit application metadata in the source code or on the Now Platform.
node_modules
Directory containing the third-party Node.js modules on which your application depends.
src
Directory containing the source code of your application, including example files. This directory includes the following subdirectories:
  • fluent: Directory containing ServiceNow Fluent code in .now.ts files. The generated subdirectory contains the application files converted to ServiceNow Fluent.
  • server: Directory containing JavaScript module code in .js or .ts files.
target
Directory containing an installable package to upload to an instance.
.eslintrc.json
File containing the ESLint configuration. ESLint helps identify and fix issues in the application code.
.gitignore
File containing a list of directories or files for Git to ignore. These files aren't tracked in source control.
now.config.json
File containing the ServiceNow application configuration. The now.config.json file must be in the base directory for an application.
You can configure the directory structure for an application by adding the following parameters. For example:
{
  "scope": "x_snc_example_app",
  "scopeId": "2f8400eb07426110f736e28f69d3017a",
  "name": "ExampleApp"
  "metadataDir": "metadata",
  "appOutputDir": "dist/app",
  "fluentDir": "src/fluent",
  "serverModulesDir": "src/server",
  "modulePaths": {
      "src/server/*.ts": "dist/server/*.js",
    },
  "ignoreTransformTableList": ["ua_table_licensing_config", "sys_embedded_help_role"]
}
package-lock.json
Auto-updated file containing complete information about dependencies and their versions. This file is only available with the ServiceNow SDK.
package.json

File containing information about your application and custom or third-party module dependencies. The package.json file must be in the base directory for an application. On an instance, the package.json path is specified in the Package JSON field of the custom application record [sys_app] in the format <scope>/<package-name>/<version>/package.json.

tsconfig.json

File containing the TypeScript configuration, type definitions, and options for compiling TypeScript files into JavaScript modules.

Related applications and features

JavaScript APIs
Use JavaScript APIs in scripts that you write to change the functionality of applications or when you create applications.