Skip to content

Commit 13ee70d

Browse files
authored
Clean update set ---- enhancement (#1948)
* Update script.js Enhancement as deletion is not a good and recommended option * Update README.md
1 parent d49aa0f commit 13ee70d

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Specialized Areas/Fix scripts/Clean update set/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Fix Script for cleaning update set from customer updates made by a selected deve
44

55
Cleaning customer updates from update set is not removing updates made in system on direct records! It is just removing customer updates from update set to not move it to forward environments.
66

7+
*******
8+
Enhancement - 8th october 2025
9+
This scrip is an enhancement to existing script and will look for the default update set(same application) and move the customer update to default update set.
10+
Deletion is not recommended way so moving to default is a better option.
11+
*******
712
**Example configuration of Fix Script**
813

914
![Coniguration](ScreenShot_3.PNG)
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
//Fix Script for cleaning an update set of customer updates made by a selected developer
22

33
//Sys_id value of the selected update set
4-
var UPDATE_SET_ID = '3f8ee93a45553010c0a05206e0e0f800';
4+
var UPDATE_SET_ID = 'fa6ec9475367e6104834d2a0a0490e63';
55

66
//Value of the selected developer (sys_user)
7-
var DEVELOPER = 'datacenterautomation@snc.maint';
7+
var DEVELOPER = 'admin';
88

99
//Query to get list of all updates in the selected update set made by the selected developer
1010
var grCustomerUpdates = new GlideRecord('sys_update_xml');
1111
grCustomerUpdates.addQuery('update_set', UPDATE_SET_ID);
1212
grCustomerUpdates.addQuery('sys_created_by', DEVELOPER);
1313
grCustomerUpdates.query();
14+
while (grCustomerUpdates.next()) {
15+
// get scope default update set
16+
grCustomerUpdates.setValue('update_set', getDefaultUpdateSet(grCustomerUpdates.getValue('application')).sys_id); // Move the customer update to default update set
17+
grCustomerUpdates.update();
18+
gs.info('[Fix Script] - Moving: ' + grCustomerUpdates.getRowCount() + ' customer updates made by: ' + DEVELOPER + ' in update set: ' + UPDATE_SET_ID + ' to ' + getDefaultUpdateSet(grCustomerUpdates.getValue('application')).name);
19+
}
1420

15-
//Logging details of Fix Script cleaning
16-
gs.info('[Fix Script] - Removing: ' + grCustomerUpdates.getRowCount() + ' customer updates made by: ' + DEVELOPER + ' in update set: ' + UPDATE_SET_ID + '.');
21+
/*
22+
Function to get Default update set (application based)
23+
input : application , type = glideRecord Object
24+
output : Default update set, type = glideRecord Object
25+
*/
1726

18-
//Remove all updates made by developer
19-
grCustomerUpdates.deleteMultiple();
27+
function getDefaultUpdateSet(application) {
28+
var updateSet = new GlideRecord('sys_update_set');
29+
updateSet.addEncodedQuery('application=' + application + '^name=Default');
30+
updateSet.query();
31+
if (updateSet.next())
32+
return updateSet;
33+
else
34+
gs.info("Default update set not found");
35+
}

0 commit comments

Comments
 (0)