Skip to content

Commit f52e0d3

Browse files
authored
Create README.md
1 parent cab3fa0 commit f52e0d3

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# 🔄 ServiceNow Fix Script: Normalize "prod" Environment Using GlideFilter
2+
3+
## 📌 Problem Statement
4+
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`
12+
13+
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"`.
19+
20+
---
21+
22+
## 🚀 Solution: Fix Script Using GlideFilter
23+
24+
We use **`GlideFilter`** with **case-sensitive matching** to cleanly and securely identify inconsistent values. This avoids multiple `if` conditions or regular expressions.
25+
26+
---
27+
28+
## ✅ Practical Example
29+
30+
Instead of writing custom logic like this:
31+
32+
```javascript
33+
var env = gr.u_environment.toString().toLowerCase();
34+
if (env === 'prod' || env === 'prod ' || env === 'PROD' || env === 'PrOd') {
35+
// Normalize
36+
}
37+
```
38+
39+
You simply write:
40+
```javascript
41+
var filter = new GlideFilter('u_environment=prod', 'envNormalize');
42+
filter.setCaseSensitive(false);
43+
if (filter.match(gr, true)) {
44+
// Normalize
45+
}
46+
```
47+
48+
✅ Cleaner
49+
✅ ACL-aware
50+
✅ Easier to maintain
51+
✅ Consistent with UI filters

0 commit comments

Comments
 (0)