Skip to content

Commit 16834f6

Browse files
authored
Create README.md
1 parent 41877af commit 16834f6

File tree

1 file changed

+64
-0
lines changed
  • Server-Side Components/Background Scripts/Duplicate Client Script Audit for Tables

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Duplicate Client Script Audit for Table
2+
3+
Detects duplicate Client Scripts created on a specific table such as Incident, Change Request, or Problem. Helps identify redundant client scripts that share the same configuration.
4+
5+
## Use Case
6+
7+
Every ServiceNow developer Junior or senior has been there, you're building something late at night, testing a client script, and you hit **“Insert and Stay”** instead of **“Update.”** It looks harmless at first until a few days later, your form starts behaving strangely because multiple client scripts with the same logic are firing at once.
8+
This script was created for exactly that situation:
9+
- It helps you **find and report duplicate client scripts** on any table, so you can clean them up before they cause issues.
10+
- It scans through active client scripts and highlights cases where multiple scripts:
11+
- Have the same **name**, **UI type**, **type**, **order**, and **field** (for *onChange* scripts)
12+
- Exist within the same table
13+
- Are still **active** in the system
14+
- By running this audit, you can quickly detect redundant client scripts that may have been unintentionally cloned
15+
16+
17+
### Functionality
18+
Uses a Background Script to:
19+
- Query all active client scripts for the selected table
20+
- Sort them by creation date (oldest to newest)
21+
- Detect duplicates with identical configurations
22+
- Display results as:
23+
- [ORIGINAL] – first created client script
24+
- This script has X duplicates – count of newer scripts with the same trigger setup
25+
- If no duplicates are found, a message confirms:
26+
- No duplicate client scripts found for this table
27+
28+
### Steps to Run
29+
30+
1. Navigate to **System Definition → Scripts - Background**
31+
2. Click **New**
32+
3. Paste the provided script and modify this line as needed:
33+
- var targetTable = 'incident'; // or 'change_request', 'wm_order' etc....
34+
4. Run Script
35+
36+
---
37+
38+
### Example:1 Run The Bacground Script For Change Request Table
39+
40+
![Duplicate Client Script Audit Output](Backgroundscript_clientscript_duplicate_4.png)
41+
42+
---
43+
44+
### Check The result from Background Script
45+
46+
![Duplicate Client Script Audit Output](Backgroundscript_clientscript_duplicate_1.png)
47+
48+
---
49+
50+
### Example:2 Run The Bacground Script For Incident Table
51+
52+
![Duplicate Client Script Audit Output](Backgroundscript_clientscript_duplicate_3.png)
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+

0 commit comments

Comments
 (0)