|
1 | | -# 🚀 ServiceNow Code Snippets |
2 | | - |
3 | | -<div align="center"> |
4 | | - |
5 | 1 |  |
6 | 2 |
|
7 | | -**A community-driven collection of ServiceNow code snippets and solutions** |
| 3 | +<div align="center"> |
8 | 4 |
|
9 | 5 | [](CONTRIBUTING.md) |
10 | 6 | [](https://github.com/ServiceNowDevProgram/Hacktoberfest) |
11 | 7 |
|
12 | | -[Explore Snippets](#-repository-structure) · [Contribute](#-how-to-contribute) · [Join Community](https://sndevs.com) |
13 | | - |
14 | 8 | </div> |
15 | 9 |
|
16 | | ---- |
17 | | - |
18 | | -## 📖 About |
19 | | - |
20 | | -Welcome to the **ServiceNow Code Snippets** repository - your go-to resource for practical, real-world ServiceNow code examples. Managed by the ServiceNow Developer Program and the vibrant **sndevs** Slack community, this repository features battle-tested code snippets submitted by developers like you. |
21 | | - |
22 | | -> 🎃 **Hacktoberfest Participant**: Check out our [main Hacktoberfest repository](https://github.com/ServiceNowDevProgram/Hacktoberfest) and [official blog post](https://devlink.sn/hacktoberfest) for more projects! |
23 | | -
|
24 | | -### ✨ What Makes This Repository Special |
25 | | - |
26 | | -- 🌍 **Community-Powered**: Real solutions from real developers |
27 | | -- 📚 **Comprehensive**: Covers all aspects of ServiceNow development |
28 | | -- 🔄 **Always Growing**: Regular updates and new snippets |
29 | | -- 🎯 **Practical**: Code you can actually use in production |
30 | | -- 🤝 **Collaborative**: Built by developers, for developers |
31 | | - |
32 | | ---- |
33 | | - |
34 | | -## 🗂️ Repository Structure |
35 | | - |
36 | | -<table> |
37 | | -<tr> |
38 | | -<td width="50%"> |
| 10 | +# ServiceNow Code Snippets Repository |
39 | 11 |
|
40 | | -### 📚 [Core ServiceNow APIs](Core%20ServiceNow%20APIs/) |
41 | | -Essential JavaScript APIs and classes |
42 | | -- GlideRecord & GlideAjax |
43 | | -- GlideSystem & GlideUser |
44 | | -- GlideDate & GlideDateTime |
45 | | -- Core utility functions |
| 12 | +Welcome to ServiceNow's Code Snippets community repository, managed by the Developer Program and the sndevs Slack community. |
46 | 13 |
|
47 | | -### ⚙️ [Server-Side Components](Server-Side%20Components/) |
48 | | -Server-executed code patterns |
49 | | -- Background Scripts |
50 | | -- Business Rules & ACLs |
51 | | -- Script Includes |
52 | | -- Scheduled Jobs & Transform Maps |
| 14 | +Inside this repository, you will find community submitted code-snippets and their variants for different use-cases. |
53 | 15 |
|
54 | | -### 🖥️ [Client-Side Components](Client-Side%20Components/) |
55 | | -Browser-based functionality |
56 | | -- Client Scripts & UI Policies |
57 | | -- Catalog Client Scripts |
58 | | -- UI Actions & UI Scripts |
59 | | -- UX Framework components |
| 16 | +**[📝 Contribution Guidelines](CONTRIBUTING.md)** | **[📚 Browse Categories](#repository-organization)** | **[🔍 How to Use](#how-to-use-this-repository)** |
60 | 17 |
|
61 | | -</td> |
62 | | -<td width="50%"> |
| 18 | +> Interested in our other ServiceNow Hacktoberfest projects? See the main repository [here](https://github.com/ServiceNowDevProgram/Hacktoberfest) or see our official blog post [here](https://devlink.sn/hacktoberfest). |
63 | 19 |
|
64 | | -### 🚀 [Modern Development](Modern%20Development/) |
65 | | -Contemporary ServiceNow approaches |
66 | | -- Service Portal widgets |
67 | | -- NOW Experience Framework |
68 | | -- GraphQL implementations |
69 | | -- ECMAScript 2021+ features |
| 20 | +**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. |
70 | 21 |
|
71 | | -### 🔗 [Integration](Integration/) |
72 | | -External system connectivity |
73 | | -- REST & SOAP integrations |
74 | | -- Mail Scripts & Webhooks |
75 | | -- MIDServer utilities |
76 | | -- Attachment handling |
| 22 | +## Disclaimer |
77 | 23 |
|
78 | | -### 🎯 [Specialized Areas](Specialized%20Areas/) |
79 | | -Domain-specific solutions |
80 | | -- CMDB & Discovery |
81 | | -- ITOM & Performance Analytics |
82 | | -- ATF Steps & Test utilities |
83 | | -- Agile Development tools |
| 24 | +Please note the following: |
84 | 25 |
|
85 | | -</td> |
86 | | -</tr> |
87 | | -</table> |
| 26 | +1. **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. |
88 | 27 |
|
89 | | ---- |
| 28 | +2. **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. |
90 | 29 |
|
91 | | -## 🚀 How to Contribute |
| 30 | +3. **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. |
92 | 31 |
|
93 | | -We'd love your contributions! Here's how to get started: |
| 32 | +4. **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. |
94 | 33 |
|
95 | | -### Quick Start |
| 34 | +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. |
96 | 35 |
|
97 | | -1. **Fork** this repository (you get a point just for forking! 🎉) |
98 | | -2. **Create** a new branch (`git checkout -b feature/amazing-snippet`) |
99 | | -3. **Add** your code snippet following our [structure guidelines](CONTRIBUTING.md) |
100 | | -4. **Commit** your changes (`git commit -m 'Add amazing snippet for X'`) |
101 | | -5. **Push** to your branch (`git push origin feature/amazing-snippet`) |
102 | | -6. **Open** a Pull Request |
| 36 | +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. |
103 | 37 |
|
104 | | -## 🌐 Contribute from the Web (No Setup Needed!) |
| 38 | +🔔🔔🔔<br> |
| 39 | +**_CONTRIBUTORS must follow all guidelines in [CONTRIBUTING.md](CONTRIBUTING.md)_** or run the risk of having your Pull Requests labeled as spam.<br> |
| 40 | +🔔🔔🔔 |
105 | 41 |
|
106 | | -You can contribute directly from your browser — no cloning required! |
| 42 | +## Table of Contents |
107 | 43 |
|
108 | | -1. Click **Fork** at the top-right corner of this page |
109 | | -2. Open the folder where you want to add or edit a file |
110 | | -3. Click **Add file → Create new file** (or edit an existing one) |
111 | | -4. Scroll down, add a **commit message**, and select |
112 | | - > "**Create a new branch for this commit and start a pull request**" |
113 | | -5. Click **Propose changes → Create pull request** |
| 44 | +- [How to Use This Repository](#how-to-use-this-repository) |
| 45 | +- [Repository Organization](#repository-organization) |
| 46 | +- [Finding Snippets](#finding-snippets) |
| 47 | +- [Folder Structure](#folder-structure) |
| 48 | +- [Contributing](#we-invite-you-to-contribute) |
| 49 | +- [Disclaimer](#disclaimer) |
114 | 50 |
|
115 | | -🎉 That’s it — your contribution will be reviewed soon! |
| 51 | +## How to Use This Repository |
116 | 52 |
|
117 | | -### 📝 Contribution Guidelines |
| 53 | +This repository contains code snippets that you can use in your ServiceNow instance. Here's how to make the most of it: |
118 | 54 |
|
119 | | -> 🔔 **IMPORTANT**: All contributors **must** follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md) or risk having PRs labeled as spam. |
| 55 | +1. **Browse by Category**: Navigate through the [six major categories](#repository-organization) to find snippets relevant to your needs. |
| 56 | +2. **Copy and Adapt**: Once you find a useful snippet, copy the code and adapt it to your specific use case in your ServiceNow instance. |
| 57 | +3. **Read the Documentation**: Each snippet folder contains a README.md file that explains how the snippet works and how to implement it. |
| 58 | +4. **Search by Topic**: Use GitHub's search functionality to find snippets by keywords (e.g., "GlideRecord", "REST", "UI Action"). |
| 59 | +5. **Contribute Your Own**: If you have a useful snippet, consider [contributing](#we-invite-you-to-contribute) to help others. |
120 | 60 |
|
121 | | -**Key Points:** |
122 | | -- Follow the existing folder structure |
123 | | -- Include clear documentation and comments |
124 | | -- Provide real-world use cases |
125 | | -- Test your code before submitting |
126 | | -- Use descriptive commit messages |
| 61 | +## Repository Organization |
127 | 62 |
|
128 | | -**Not sure where to start?** Check out issues labeled `good-first-issue` or `help-wanted`! |
| 63 | +The repository is organized into **6 major categories** that cover all aspects of ServiceNow development: |
129 | 64 |
|
130 | | ---- |
131 | | - |
132 | | -## ⚠️ Important Disclaimer |
133 | | - |
134 | | -<details> |
135 | | -<summary>Click to read full disclaimer</summary> |
136 | | - |
137 | | -### Community-Sourced Content |
138 | | - |
139 | | -**Please note the following:** |
140 | | - |
141 | | -1. **Not Officially Endorsed**: Code in this repository is community-contributed and not officially vetted or endorsed by ServiceNow or repository owners. |
142 | | - |
143 | | -2. **Use at Your Own Risk**: Always review code thoroughly before implementing in your ServiceNow instances. Test in sub-production environments first. |
144 | | - |
145 | | -3. **Report Issues**: Found a bug or improvement? Please [open an issue](../../issues) or submit a correction. |
146 | | - |
147 | | -4. **No Warranty**: This repository is provided "as-is" without warranties or guarantees. No official support is provided. |
| 65 | +### 📚 [Core ServiceNow APIs](Core%20ServiceNow%20APIs/) |
| 66 | +Essential ServiceNow JavaScript APIs and classes including GlideRecord, GlideAjax, GlideSystem, GlideDate, GlideDateTime, and other foundational APIs. |
148 | 67 |
|
149 | | -5. **Security First**: Always validate code against your organization's security standards before deployment. |
| 68 | +### ⚙️ [Server-Side Components](Server-Side%20Components/) |
| 69 | +Server-side code including Background Scripts, Business Rules, Script Includes, Scheduled Jobs, Transform Map Scripts, and other server-executed components. |
150 | 70 |
|
151 | | -**By using code from this repository, you acknowledge you've read and understood this disclaimer.** |
| 71 | +### 🖥️ [Client-Side Components](Client-Side%20Components/) |
| 72 | +Client-side code including Client Scripts, Catalog Client Scripts, UI Actions, UI Scripts, UI Pages, and UX framework components. |
152 | 73 |
|
153 | | -</details> |
| 74 | +### 🚀 [Modern Development](Modern%20Development/) |
| 75 | +Modern ServiceNow development approaches including Service Portal, NOW Experience Framework, GraphQL implementations, and ECMAScript 2021 features. |
154 | 76 |
|
155 | | ---- |
| 77 | +### 🔗 [Integration](Integration/) |
| 78 | +External system integrations, data import/export utilities, RESTMessageV2 examples, Mail Scripts, MIDServer utilities, and attachment handling. |
156 | 79 |
|
157 | | -## 🏆 Recognition |
| 80 | +### 🎯 [Specialized Areas](Specialized%20Areas/) |
| 81 | +Domain-specific functionality including CMDB utilities, ITOM scripts, Performance Analytics, ATF Steps, Agile Development tools, and other specialized use cases. |
158 | 82 |
|
159 | | -View our contributor leaderboard and stats in the [Hacktoberfest repository](https://github.com/ServiceNowDevProgram/Hacktoberfest#leaders)! |
| 83 | +## Finding Snippets |
160 | 84 |
|
161 | | ---- |
| 85 | +There are several ways to find the snippets you need: |
162 | 86 |
|
163 | | -## 🌐 Community & Resources |
| 87 | +1. **By Category**: Browse the six major categories listed above. |
| 88 | +2. **By Search**: Use GitHub's search functionality with keywords like: |
| 89 | + - API names: `GlideRecord`, `GlideSystem`, `GlideAjax` |
| 90 | + - Component types: `Business Rule`, `Client Script`, `UI Action` |
| 91 | + - Functionality: `REST`, `SOAP`, `Import`, `Export` |
| 92 | + - Use cases: `Authentication`, `Notification`, `Workflow` |
164 | 93 |
|
165 | | -<div align="center"> |
| 94 | +3. **By Tags**: Many snippets include common keywords in their README files that can be searched. |
166 | 95 |
|
167 | | -| Resource | Description | |
168 | | -|----------|-------------| |
169 | | -| [sndevs Slack](https://sndevs.com) | Join thousands of ServiceNow developers | |
170 | | -| [Developer Portal](https://developer.servicenow.com) | Official ServiceNow documentation | |
171 | | -| [Community Forum](https://www.servicenow.com/community/) | Ask questions and share knowledge | |
172 | | -| [Developer Blog](https://developer.servicenow.com/blog.do) | Latest news and tutorials | |
| 96 | +## Folder Structure |
173 | 97 |
|
174 | | -</div> |
| 98 | +The repository follows a consistent structure to make navigation easier: |
175 | 99 |
|
176 | | ---- |
| 100 | +``` |
| 101 | +Top-Level Category/ |
| 102 | + ├── Sub-Category/ |
| 103 | + │ ├── Specific Snippet/ |
| 104 | + │ │ ├── README.md # Description and usage instructions |
| 105 | + │ │ ├── snippet_file.js # The actual code snippet |
| 106 | + │ │ └── variant.js # Variations of the snippet (if applicable) |
| 107 | +``` |
177 | 108 |
|
178 | | -## 📄 License |
| 109 | +For example: |
| 110 | +``` |
| 111 | +Core ServiceNow APIs/ |
| 112 | + ├── GlideRecord/ |
| 113 | + │ ├── Query Performance Optimization/ |
| 114 | + │ │ ├── README.md |
| 115 | + │ │ ├── basic_query.js |
| 116 | + │ │ └── optimized_query.js |
| 117 | +``` |
179 | 118 |
|
180 | | -This repository is available under the MIT License. See [LICENSE](LICENSE) for more details. |
| 119 | +## We invite you to contribute! |
181 | 120 |
|
182 | | ---- |
| 121 | +We welcome contributions from the ServiceNow developer community! Your knowledge and experience can help others solve common challenges. |
183 | 122 |
|
184 | | -## 🙏 Acknowledgments |
| 123 | +## 🌐 Contribute from the Web (No Setup Needed!) |
185 | 124 |
|
186 | | -Special thanks to: |
187 | | -- All our amazing [contributors](../../graphs/contributors) |
188 | | -- The ServiceNow Developer Program team |
189 | | -- The sndevs community moderators |
190 | | -- Everyone who has starred, forked, or shared this project |
| 125 | +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: |
191 | 126 |
|
192 | | ---- |
| 127 | +1. Click **Fork** at the top-right corner of this page |
| 128 | +2. Open the folder where you want to add or edit a file |
| 129 | +3. Click **Add file → Create new file** (or edit an existing one) |
| 130 | +4. Scroll down, add a **commit message**, and select |
| 131 | + > "**Create a new branch for this commit and start a pull request**" |
| 132 | +5. Click **Propose changes → Create pull request** |
193 | 133 |
|
194 | | -<div align="center"> |
| 134 | +That's it! **For detailed contribution instructions, please read our [CONTRIBUTING.md](CONTRIBUTING.md) guide before submitting.** |
195 | 135 |
|
196 | | -**⭐ Star this repo if you find it helpful!** |
| 136 | +### What makes a good contribution? |
197 | 137 |
|
198 | | -Made with ❤️ by the ServiceNow Developer Community |
| 138 | +- **Useful snippets** that solve common ServiceNow development challenges |
| 139 | +- **Well-documented code** with clear comments explaining how it works |
| 140 | +- **Proper organization** following the repository structure |
| 141 | +- **Variations** of snippets for different use cases when applicable |
199 | 142 |
|
200 | | -[Report Bug](../../issues) · [Request Feature](../../issues) · [View Statistics](../../pulse) |
| 143 | +## Leaderboard |
201 | 144 |
|
202 | | -</div> |
| 145 | +Looking for the old leaderboard? We've moved the leaderboard to the overarching [Hacktoberfest](https://github.com/ServiceNowDevProgram/Hacktoberfest#leaders) repository and have expanded its scope to all participating projects. |
0 commit comments