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+ }
0 commit comments