Welcome to ServiceNow's Code Snippets community repository, managed by the Developer Program and the sndevs Slack community.
Inside this repository, you will find community submitted code-snippets and their variants for different use-cases.
π Contribution Guidelines | π Browse Categories | π How to Use
Interested in our other ServiceNow Hacktoberfest projects? See the main repository here or see our official blog post here.
Note: ServiceNowDevProgram has many repositories that can be imported directly into ServiceNow, this is not one of them; This repository is meant to be edited directly in GitHub or any other Git-enabled IDE like VS Code.
Please note the following:
-
Community-Sourced Code: The code found in this repository is contributed by members of the community and has not been vetted or officially endorsed by the repository owners.
-
Use at Your Own Risk: Users are advised to exercise caution and thoroughly review the code before implementing it in their ServiceNow instances. We strongly recommend a comprehensive review to ensure the code aligns with your specific requirements and security standards.
-
Reporting Mistakes and Issues: If you come across any mistakes, issues, or improvements in the code, we encourage you to report them and consider contributing to the repository by submitting corrections or enhancements.
-
No Warranty or Support: This repository is provided as-is, without any warranties or guarantees. It does not come with official support from the ServiceNow team or the repository owners.
By using the code from this repository, you acknowledge that you have read and understood this disclaimer. Your use of the code is at your own discretion and risk.
We appreciate your participation and contributions to this community-driven project. Let's collaborate to make it a valuable resource for ServiceNow developers and enthusiasts.
πππ
CONTRIBUTORS must follow all guidelines in CONTRIBUTING.md or run the risk of having your Pull Requests labeled as spam.
πππ
- How to Use This Repository
- Repository Organization
- Finding Snippets
- Folder Structure
- Contributing
- Disclaimer
This repository contains code snippets that you can use in your ServiceNow instance. Here's how to make the most of it:
- Browse by Category: Navigate through the six major categories to find snippets relevant to your needs.
- Copy and Adapt: Once you find a useful snippet, copy the code and adapt it to your specific use case in your ServiceNow instance.
- Read the Documentation: Each snippet folder contains a README.md file that explains how the snippet works and how to implement it.
- Search by Topic: Use GitHub's search functionality to find snippets by keywords (e.g., "GlideRecord", "REST", "UI Action").
- Contribute Your Own: If you have a useful snippet, consider contributing to help others.
The repository is organized into 6 major categories that cover all aspects of ServiceNow development:
π Core ServiceNow APIs
Essential ServiceNow JavaScript APIs and classes including GlideRecord, GlideAjax, GlideSystem, GlideDate, GlideDateTime, and other foundational APIs.
βοΈ Server-Side Components
Server-side code including Background Scripts, Business Rules, Script Includes, Scheduled Jobs, Transform Map Scripts, and other server-executed components.
π₯οΈ Client-Side Components
Client-side code including Client Scripts, Catalog Client Scripts, UI Actions, UI Scripts, UI Pages, and UX framework components.
π Modern Development
Modern ServiceNow development approaches including Service Portal, NOW Experience Framework, GraphQL implementations, and ECMAScript 2021 features.
π Integration
External system integrations, data import/export utilities, RESTMessageV2 examples, Mail Scripts, MIDServer utilities, and attachment handling.
π― Specialized Areas
Domain-specific functionality including CMDB utilities, ITOM scripts, Performance Analytics, ATF Steps, Agile Development tools, and other specialized use cases.
There are several ways to find the snippets you need:
-
By Category: Browse the six major categories listed above.
-
By Search: Use GitHub's search functionality with keywords like:
- API names:
GlideRecord
,GlideSystem
,GlideAjax
- Component types:
Business Rule
,Client Script
,UI Action
- Functionality:
REST
,SOAP
,Import
,Export
- Use cases:
Authentication
,Notification
,Workflow
- API names:
-
By Tags: Many snippets include common keywords in their README files that can be searched.
The repository follows a consistent structure to make navigation easier:
Top-Level Category/
βββ Sub-Category/
β βββ Specific Snippet/
β β βββ README.md # Description and usage instructions
β β βββ snippet_file.js # The actual code snippet
β β βββ variant.js # Variations of the snippet (if applicable)
For example:
Core ServiceNow APIs/
βββ GlideRecord/
β βββ Query Performance Optimization/
β β βββ README.md
β β βββ basic_query.js
β β βββ optimized_query.js
We welcome contributions from the ServiceNow developer community! Your knowledge and experience can help others solve common challenges.
This repository has been approved by Hacktoberfest in spirit of learning source control and getting started in your open-source journey. You can contribute directly from your browser without needing a ServiceNow instance:
- Click Fork at the top-right corner of this page
- Open the folder where you want to add or edit a file
- Click Add file β Create new file (or edit an existing one)
- Scroll down, add a commit message, and select
"Create a new branch for this commit and start a pull request"
- Click Propose changes β Create pull request
That's it! For detailed contribution instructions, please read our CONTRIBUTING.md guide before submitting.
- Useful snippets that solve common ServiceNow development challenges
- Well-documented code with clear comments explaining how it works
- Proper organization following the repository structure
- Variations of snippets for different use cases when applicable
Looking for the old leaderboard? We've moved the leaderboard to the overarching Hacktoberfest repository and have expanded its scope to all participating projects.