Check update-set, updateset checker

PHOTO EMBED

Fri Sep 22 2023 03:32:38 GMT+0000 (Coordinated Universal Time)

Saved by @RahmanM

/*
    Find all the update-sets that are WIP and the customer updates contains more than one applications
*/

//-------------------------------------------------------------------------------------------------------------
// If we want specific users e.g. if there are multiple partners and we want only our techs then add them to
// the list below else clear the list!
//-------------------------------------------------------------------------------------------------------------
var createdByUsers = [
    'zeb.granada@valueflow.com.au', 
    'Nadia.Co@valueflow.com.au',
    'rahman.mahmoodi@valueflow.com.au',
    'loraine.frendo@valueflow.com.au',
    'Dharmesh.Jani@valueflow.com.au'
    ];
    
    //-------------------------------------------------------------------------------------------------------------
    // Go through all the Update-sets that are WIP 
    // Ignore the Default update-sets
    //-------------------------------------------------------------------------------------------------------------
    var grSysUpdateSet = new GlideRecord('sys_update_set');
    grSysUpdateSet.addQuery('state', 'in progress');
    grSysUpdateSet.addQuery('name', '!=', 'Default');
    
    //-------------------------------------------------------------------------------------------------------------
    // If users list exist then add it to the query
    //-------------------------------------------------------------------------------------------------------------
    if(createdByUsers && createdByUsers.length > 0){
        var createdByUsersQuery = createdByUsers.join(',').trim(',');
        grSysUpdateSet.addQuery('sys_created_by', 'IN', createdByUsersQuery);
    }
    
    grSysUpdateSet.query();
    
    // Distinct Update-set names
    var distinctXMLList = [];
    
    while (grSysUpdateSet.next()) {
    
        //-------------------------------------------------------------------------------------------------------------
        // Find all the customer updates that belongs to this update-set and are different than the update-set application
        //-------------------------------------------------------------------------------------------------------------
        var grCustomerUpdates = new GlideRecord('sys_update_xml');
        grCustomerUpdates.addQuery("update_set.sys_id", grSysUpdateSet.getUniqueValue());
        grCustomerUpdates.addQuery("application", '!=', grSysUpdateSet.getValue('application'));
        grCustomerUpdates.query();
    
    
        while (grCustomerUpdates.next()) {
            
            // Don't report the same update-set name more than once, as long as it is reported once is enough!!
            if(distinctXMLList.indexOf(grSysUpdateSet.getValue('name')) == -1){
                gs.debug('-------------------------------------------------------------------------------------------------------------');
                gs.debug('Found an update-set that its customer updates has more than one applications (at least)!');
                gs.debug('-------------------------------------------------------------------------------------------------------------');
                gs.debug('Update-set name (sys_update_set): ' + grSysUpdateSet.getValue('name'));
                gs.debug('Update-set owner: ' + grSysUpdateSet.getDisplayValue('sys_created_by'));
                gs.debug('Customer updates owner [offender ;-)]: ' + grCustomerUpdates.getDisplayValue('sys_created_by'));
                gs.debug('-------------------------------------------------------------------------------------------------------------');
            
                distinctXMLList.push(grSysUpdateSet.getValue('name'));
            }
        }
        
    }
content_copyCOPY

check updatesets for cross application