Skip to content

Commit 25b447e

Browse files
authored
Update-set cross scope checker. (#1137)
1 parent 1983e7b commit 25b447e

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Find all the update-sets that are WIP and the customer updates contains more than one applications
3+
*/
4+
5+
//-------------------------------------------------------------------------------------------------------------
6+
// If we want specific users e.g. if there are multiple partners and we want only our techs then add them to
7+
// the list below else clear the list!
8+
//-------------------------------------------------------------------------------------------------------------
9+
var createdByUsers = [
10+
// TODO: Add your specific user user_name based on sys_user table
11+
];
12+
13+
//-------------------------------------------------------------------------------------------------------------
14+
// Go though all the Update-sets that are WIP or alternatively add the filter to grab for specific users
15+
// Ignore the Default update-sets
16+
//-------------------------------------------------------------------------------------------------------------
17+
var grSysUpdateSet = new GlideRecord('sys_update_set');
18+
grSysUpdateSet.addQuery('state', 'in progress');
19+
grSysUpdateSet.addQuery('name', '!=', 'Default');
20+
21+
//-------------------------------------------------------------------------------------------------------------
22+
// If users list exist then add it to the query
23+
//-------------------------------------------------------------------------------------------------------------
24+
if(createdByUsers && createdByUsers.length > 0){
25+
var createdByUsersQuery = createdByUsers.join(',').trim(',');
26+
grSysUpdateSet.addQuery('sys_created_by', 'IN', createdByUsersQuery);
27+
}
28+
29+
grSysUpdateSet.query();
30+
31+
// Distinct Update-set names
32+
var distinctXMLList = [];
33+
34+
while (grSysUpdateSet.next()) {
35+
36+
//-------------------------------------------------------------------------------------------------------------
37+
// Find all the customer updates belongs to this update-set and are different than the update-set application
38+
//-------------------------------------------------------------------------------------------------------------
39+
var grCustomerUpdates = new GlideRecord('sys_update_xml');
40+
grCustomerUpdates.addQuery("update_set.sys_id", grSysUpdateSet.getUniqueValue());
41+
grCustomerUpdates.addQuery("application", '!=', grSysUpdateSet.getValue('application'));
42+
grCustomerUpdates.query();
43+
44+
45+
while (grCustomerUpdates.next()) {
46+
47+
// Don't report the same update-set name more than once, as long as it is reported once is enough!!
48+
if(distinctXMLList.indexOf(grSysUpdateSet.getValue('name')) == -1){
49+
gs.debug('-------------------------------------------------------------------------------------------------------------');
50+
gs.debug('Found an update-set that its customer updates has more than one applications (at least)!');
51+
gs.debug('-------------------------------------------------------------------------------------------------------------');
52+
gs.debug('Update-set name (sys_update_set): ' + grSysUpdateSet.getValue('name'));
53+
gs.debug('Update-set application: ' + grSysUpdateSet.getDisplayValue('application'));
54+
gs.debug('Customer updates application (sys_update_xml.application): ' + grCustomerUpdates.getDisplayValue('application'));
55+
gs.debug('-------------------------------------------------------------------------------------------------------------');
56+
57+
distinctXMLList.push(grSysUpdateSet.getValue('name'));
58+
}
59+
}
60+
61+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Check all Work in Progress update-sets for Cross Application Scopes
2+
If an update-set has more than one application scope it will cause issues when you are previewing the update-set in the target instance. Therefore, it is the best to check the update-sets before closing and retrieving them to the target instance.
3+
4+
This sample script, checks all the WIP update-sets and find the update-sets that has more than one Application Scope in them. It will show which update-set and whose update is causing it.

0 commit comments

Comments
 (0)