Skip to content

Commit 76e2f2e

Browse files
authored
Create Normalize_All_Variants_of_prod.js
1 parent f52e0d3 commit 76e2f2e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Create this as fix script or run as background script as per your requirement
2+
(function normalizeProdWithGlideFilter() {
3+
var changeGR = new GlideRecord('change_request');
4+
changeGR.addNotNullQuery('u_environment');
5+
changeGR.query();
6+
7+
var filter = new GlideFilter('u_environment=prod', 'normalizeProdFilter');
8+
filter.setCaseSensitive(false); // Match any case variant of "prod"
9+
filter.setEnforceSecurity(true); // Enforce ACLs
10+
11+
var updated = 0;
12+
13+
while (changeGR.next()) {
14+
if (filter.match(changeGR, true)) {
15+
var original = changeGR.u_environment.toString();
16+
17+
if (original !== 'Prod') {
18+
changeGR.u_environment = 'Prod';
19+
changeGR.update();
20+
updated++;
21+
}
22+
}
23+
}
24+
gs.info('✔️ Environment normalization completed. Total updated: ' + updated);
25+
})();

0 commit comments

Comments
 (0)