Building applications in source code
Summarize
Summary of Building applications in source code
ServiceNow enables you to create and develop custom applications in source code using familiar development tools and processes. You can build applications either using the online ServiceNow IDE on the ServiceNow AI Platform or locally in Visual Studio Code Desktop with the ServiceNow SDK. Both environments utilizeServiceNow Fluent, a domain-specific language for defining application metadata, supported by APIs for managing metadata types. You can also include JavaScript modules and third-party libraries to enhance code reuse and application complexity.
Show less
Developing in source code allows you to work within familiar environments, manage complex applications efficiently, leverage source control integration, and catch errors early during build time.
ServiceNow IDE vs ServiceNow SDK
- ServiceNow IDE: An online, web-based IDE built on Visual Studio Code for the Web, hosted on the ServiceNow AI Platform. It supports real-time collaboration by viewing user changes directly and integrates with Git for source control, allowing one concurrent branch per repository per instance or sandbox. It includes the ServiceNow Fluent Language Server and supports Now Assist for Code for script autocomplete, as well as Build Agent accessed via a chat panel.
- ServiceNow SDK: A local development environment using Visual Studio Code Desktop that allows offline work. Collaboration is managed through syncing changes with an instance using the ServiceNow SDK CLI and Git source control. The Fluent Language Server is available via Visual Studio Code extensions. It supports JavaScript modules and third-party libraries and includes Build Agent skills starting from version 4.6.0 but does not support Now Assist for Code.
Both environments support converting existing applications not originally created with these tools.
Application Structure in Source Code
Applications created or converted with the ServiceNow IDE or SDK have a Node.js-like structure defined by package.json and now.config.json files. This structure supports modular and organized development:
- .vscode/: Recommended VS Code extensions.
- dist/: Build artifacts organized into
app/for metadata XML files andstatic/for static assets. - metadata/: Stores application metadata XML files (not intended to be edited directly).
- nodemodules/: Third-party Node.js modules dependencies.
- src/: Source code including
client/(UI files),fluent/(ServiceNow Fluent .now.ts files), andserver/(JavaScript or TypeScript modules). - target/: Contains the installable package zip file for instance upload.
- Configuration and support files such as
.eslintrc(linting rules),.gitignore(Git exclusions),now.config.json(application configuration), and files managing dependencies (package.json,package-lock.json,now.prebuild.mjs).
The now.config.json file allows customization of the application structure and features.
Practical Benefits for ServiceNow Customers
- Create and maintain complex applications with familiar tools like Visual Studio Code.
- Work collaboratively in real time (ServiceNow IDE) or through source control workflows (SDK).
- Leverage ServiceNow Fluent for defining application metadata programmatically and consistently.
- Incorporate JavaScript modules and third-party libraries to optimize development.
- Use integrated tooling such as ESLint to maintain code quality and Build Agent to automate builds.
- Customize application packaging and configuration to fit specific development needs.
Related Capabilities
- JavaScript APIs for scripting application behavior.
- UI development using React.
- Advanced application configuration options through source code.
Create and develop custom applications in source code using familiar development tools and processes.
Overview of development in source code
You can create applications in code using the ServiceNow IDE on the ServiceNow AI 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 an application scope.
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.
|
ServiceNow IDE |
ServiceNow SDK |
Comparison of the ServiceNow IDE and the ServiceNow SDK
| Feature | ServiceNow IDE | ServiceNow SDK |
|---|---|---|
| Development environment | Online ServiceNow instance | Local development and the ability to work offline |
| User interface | IDE based on Visual Studio Code for the Web | Visual Studio Code Desktop |
| Collaboration | View any user's changes in real time in code or embedded ServiceNow AI Platform user interfaces. Collaborate with other developers on applications in source control. |
Download changes from an instance and install local changes to an instance using the ServiceNow SDK CLI to collaborate with other users. Collaborate with other developers on applications in source control. |
| Source control | Supports the most common Git functionality and integrating with a Git provider of your choice. One concurrent branch per repository per instance (or developer sandbox). |
Full support |
| Application conversion | Support for converting existing applications not created with the ServiceNow IDE or ServiceNow SDK. | Support for converting existing applications not created with the ServiceNow IDE or ServiceNow SDK. |
| ServiceNow Fluent | Full support The ServiceNow Fluent Language server is included with the ServiceNow IDE. |
Full support The ServiceNow Fluent Language server can be installed from the Visual Studio Code Extension Marketplace. |
| JavaScript modules and third-party libraries | Full support | Full support |
| Now Assist for Code | Code auto-complete support for scripts. For information about activation, see Now Assist for Code. |
Not supported |
| Build Agent | Full support. Build Agent is accessed from a chat panel in the ServiceNow IDE. For information about activation, see Build Agent. |
Build Agent skills are available beginning with ServiceNow SDK version 4.6.0. |
Application structure
Applications created or converted 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.
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.
| Directory or file | Description |
|---|---|
| .vscode | Directory containing recommended Visual Studio Code extensions. |
| dist | Directory containing the build artifacts for packaging. This directory includes the following subdirectories:
|
| 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 ServiceNow AI 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. This directory includes the following subdirectories:
|
| target | Directory containing an installable package (.zip file) to upload to an instance. |
| .eslintrc | 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 aspects of an application by adding support parameters. For more information, see Custom application configuration in source code. |
| now.prebuild.mjs | Auto-updated file containing complete information about dependencies and their versions. This file is only available with the ServiceNow SDK. |
| 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. |
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.