diff --git a/Specialized Areas/Fix scripts/Clean update set/README.md b/Specialized Areas/Fix scripts/Clean update set/README.md index 36273b79c7..5188fb0623 100644 --- a/Specialized Areas/Fix scripts/Clean update set/README.md +++ b/Specialized Areas/Fix scripts/Clean update set/README.md @@ -4,6 +4,11 @@ Fix Script for cleaning update set from customer updates made by a selected deve 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. +******* +Enhancement - 8th october 2025 +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. +Deletion is not recommended way so moving to default is a better option. +******* **Example configuration of Fix Script** ![Coniguration](ScreenShot_3.PNG) diff --git a/Specialized Areas/Fix scripts/Clean update set/script.js b/Specialized Areas/Fix scripts/Clean update set/script.js index f152ea7bd6..20c0d8e190 100644 --- a/Specialized Areas/Fix scripts/Clean update set/script.js +++ b/Specialized Areas/Fix scripts/Clean update set/script.js @@ -1,19 +1,35 @@ //Fix Script for cleaning an update set of customer updates made by a selected developer //Sys_id value of the selected update set -var UPDATE_SET_ID = '3f8ee93a45553010c0a05206e0e0f800'; +var UPDATE_SET_ID = 'fa6ec9475367e6104834d2a0a0490e63'; //Value of the selected developer (sys_user) -var DEVELOPER = 'datacenterautomation@snc.maint'; +var DEVELOPER = 'admin'; //Query to get list of all updates in the selected update set made by the selected developer var grCustomerUpdates = new GlideRecord('sys_update_xml'); grCustomerUpdates.addQuery('update_set', UPDATE_SET_ID); grCustomerUpdates.addQuery('sys_created_by', DEVELOPER); grCustomerUpdates.query(); +while (grCustomerUpdates.next()) { + // get scope default update set + grCustomerUpdates.setValue('update_set', getDefaultUpdateSet(grCustomerUpdates.getValue('application')).sys_id); // Move the customer update to default update set + grCustomerUpdates.update(); + gs.info('[Fix Script] - Moving: ' + grCustomerUpdates.getRowCount() + ' customer updates made by: ' + DEVELOPER + ' in update set: ' + UPDATE_SET_ID + ' to ' + getDefaultUpdateSet(grCustomerUpdates.getValue('application')).name); +} -//Logging details of Fix Script cleaning -gs.info('[Fix Script] - Removing: ' + grCustomerUpdates.getRowCount() + ' customer updates made by: ' + DEVELOPER + ' in update set: ' + UPDATE_SET_ID + '.'); +/* +Function to get Default update set (application based) +input : application , type = glideRecord Object +output : Default update set, type = glideRecord Object +*/ -//Remove all updates made by developer -grCustomerUpdates.deleteMultiple(); +function getDefaultUpdateSet(application) { + var updateSet = new GlideRecord('sys_update_set'); + updateSet.addEncodedQuery('application=' + application + '^name=Default'); + updateSet.query(); + if (updateSet.next()) + return updateSet; + else + gs.info("Default update set not found"); +}