Skip to content

Commit f12e855

Browse files
authored
Update readme.md, combine both scripts into 1 readme
1 parent ee88421 commit f12e855

File tree

1 file changed

+25
-5
lines changed
  • Server-Side Components/Background Scripts/Duplicate Finder

1 file changed

+25
-5
lines changed

Server-Side Components/Background Scripts/Duplicate Finder/readme.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
## ServiceNow Duplicate Record Finder
2-
A simple server-side script for ServiceNow that finds and reports on duplicate values for any field on any table. It uses an efficient GlideAggregate query and formats the results into a clean, readable report.
3-
1+
# ServiceNow Duplicate Record Finder
2+
A simple server-side script for ServiceNow that finds and reports on duplicate values for any field on any table. It uses an efficient `GlideAggregate` query.
3+
## Find Duplicates by Single Field - `findDuplicatesBySingleField.js`
4+
This finds duplicates based on a single field which matches
45
### How to Use
56
This script is designed to be run in **Scripts - Background** or as a Fix Script.
67
1. Navigate: Go to **System Definition > Scripts - Background** (or type sys.scripts.do in the filter navigator).
7-
2. Copy Script: Copy the entire contents of the script.js file.
8+
2. Copy Script: Copy the entire contents of the `findDuplicatesBySingleField.js` file.
89
3. Paste and Configure: Paste the script into the "Run script" text box. Add the table to search in `tableName` and the field to search for duplicates in `fieldName`
910
```js
1011
// Update ONLY below values to find duplicates
@@ -22,6 +23,25 @@ This script is designed to be run in **Scripts - Background** or as a Fix Script
2223
var fieldName = 'short_description';
2324
```
2425

25-
2626
4. Run Script: Click the "Run script" button. The results will be displayed on the screen below the editor.
2727

28+
## Find Duplicates by Field Combination - `findDuplicatesByCombination.js`
29+
This is a more powerful script that finds duplicate records based on a unique combination of one or more fields.
30+
31+
### How to use
32+
This script is also designed to be run in **Scripts - Background**
33+
1. Navigate: Go to **System Definition > Scripts - Background**
34+
2. Copy Script: Copy the entire contents of the `findDuplicatesByCombination.js` file.
35+
3. Paste and Configure: Paste the script into the "Run script" text box. Update the `tableName` field and the `fieldNames` array. The `fieldNames` variable is an array, so even a single field must be enclosed in square brackets `[]`
36+
37+
```js
38+
// --- UPDATE ONLY THE VALUES BELOW ---
39+
var tableName = '<table_name>'; // The table you want to check.
40+
var fieldNames = ['field_1', 'field_2']; // An array of fields for the unique combination.
41+
```
42+
43+
For example, to find models with the same name, model number and manufacturer
44+
```js
45+
var tableName = 'cmdb_model';
46+
var fieldNames = ['name', 'model_number', 'manufacturer'];
47+
```

0 commit comments

Comments
 (0)