Skip to content

Commit 5ad0e8e

Browse files
authored
Create readme.md
1 parent ef3226b commit 5ad0e8e

File tree

1 file changed

+30
-0
lines changed
  • Specialized Areas/Fix scripts/Remove extra spaces

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## ServiceNow Fix Script: Remove Extra Spaces
2+
A generic ServiceNow fix script to clean data by removing extra whitespace from any specified field on any table.
3+
4+
### Problem It Solves
5+
This script resolves data integrity issues caused by inconsistent user input, such as:
6+
- Leading or trailing spaces (e.g., " Hello World ").
7+
- Multiple spaces between words (e.g., "Hello World").
8+
9+
### How to use
10+
1. Create and Configure the Fix Script
11+
- First, create a new Fix Script in your ServiceNow instance (**System Definition > Fix Scripts**) add past the code
12+
13+
2. Add your table name and field that you want to clean up
14+
- Before running, you must update the following variables inside the script to define your target:
15+
```js
16+
var tableName = 'incident'; // <-- CHANGE THIS to your table name
17+
var fieldName = 'short_description'; // <-- CHANGE THIS to your field name
18+
```
19+
20+
3. Change `processRecords` value and run
21+
- To see what changes will be made without actually updating records, ensure the `processRecords` variable in the script is set to `false`
22+
```js
23+
var processRecords = false;
24+
```
25+
- To actually do the update, change the `processRecords` variable to `true` and run the script
26+
```js
27+
var processRecords = true;
28+
```
29+
30+
4. Run the script

0 commit comments

Comments
 (0)