Skip to content

Commit 627161e

Browse files
authored
Update README.md
1 parent e876d8d commit 627161e

File tree

1 file changed

+14
-47
lines changed

1 file changed

+14
-47
lines changed
Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
1-
# 🔄 ServiceNow Fix Script: Normalize "prod" Environment Using GlideFilter
1+
# ServiceNow Fix Script: Normalize "prod" Environment Using GlideFilter
22

3-
## 📌 Problem Statement
3+
## Problem Statement
44

5-
In many ServiceNow environments, custom fields like `u_environment` on tables such as `change_request` often contain inconsistent variants of the same logical value, for example:
6-
7-
- `prod`
8-
- `PROD`
9-
- `Prod`
10-
- `PrOd`
11-
- `pRoD`
5+
In many ServiceNow environments, custom fields like `u_environment` on tables such as `change_request` often contain inconsistent variants of the same logical value, for example: `prod`, `PROD`, `Prod`,`PrOd`, `pRoD` etc.
126

137
These inconsistencies cause:
14-
- Confusion in reports
15-
- Broken automation rules
16-
- Poor data hygiene
17-
18-
This script identifies and normalizes all case-variant values of `"prod"` to a consistent format: `"Prod"`.
8+
- Bad or inconsistent reports
9+
- Broken automation rules like BR or flow with condition
10+
- And, Poor data hygiene or dirty values
1911

2012
---
2113

22-
## 🚀 Solution: Fix Script Using GlideFilter
14+
## Solution: Fix Script or Background Script Using GlideFilter
2315

24-
We use **`GlideFilter`** with **case-sensitive matching** to cleanly and securely identify inconsistent values. This avoids multiple `if` conditions or regular expressions.
16+
We use **`GlideFilter`** with **case-sensitive matching** to securely identify inconsistent values to avoid multiple `if` conditions or regular expressions.
2517

2618
---
2719

28-
## ✅ Practical Example
20+
## Example
2921

30-
Instead of writing custom logic like this:
22+
Instead of writing custom logic with if statement like this:
3123

3224
```javascript
3325
var env = gr.u_environment.toString().toLowerCase();
@@ -36,7 +28,7 @@ if (env === 'prod' || env === 'prod ' || env === 'PROD' || env === 'PrOd') {
3628
}
3729
```
3830

39-
You simply write:
31+
You can simply write:
4032
```javascript
4133
var filter = new GlideFilter('u_environment=prod', 'envNormalize');
4234
filter.setCaseSensitive(false);
@@ -45,32 +37,7 @@ if (filter.match(gr, true)) {
4537
}
4638
```
4739

48-
✅ Cleaner
49-
✅ ACL-aware
50-
✅ Easier to maintain
51-
✅ Consistent with UI filters
52-
53-
## GlideFilter Utility
54-
55-
🧠 **Why Use GlideFilter?**
56-
57-
| Feature | GlideFilter | Regex / If |
58-
|---------------------------------|-------------|------------|
59-
| Security-aware (ACLs) | ✅ Yes | ❌ No |
60-
| Case sensitivity toggle | ✅ Yes | ⚠️ Manual |
61-
| UI-like filter syntax | ✅ Yes | ❌ No |
62-
| Easy to read | ✅ Yes | ❌ No |
63-
| Scalable & reusable | ✅ Yes | ❌ No |
64-
| Compound condition support | ✅ Yes | ⚠️ Complex to build |
65-
66-
💡 **Use Cases**
67-
- Normalizing environment values (prod, dev, test)
68-
- Standardizing priority or category values
69-
- Filtering GlideRecords based on secure, compound conditions
70-
- Any script where you're mimicking UI filter logic in code
71-
72-
🛠️ **How to Use**
73-
1. Go to **System Definition****Scripts - Background**.
74-
2. Paste the script above.
40+
## **How to Use**
41+
1. Go to **Scripts - Background** or **Fix Scripts**.
42+
2. Define the script using above glidefilter example shared.
7543
3. Click **Run Script**.
76-
4. Check **System Logs** (gs.info) to verify updates.

0 commit comments

Comments
 (0)