Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

unable to capture the deleted records of sys_portal and sys_portal_preferences in update set

Community Alums
Not applicable

I am unable to capture the deleted records of sys_portal and sys_portal_preferences in update set.
This is needed because we have to remove these records from Production, hence trying to capture the deletion in lower instances. Merely moving the xmls will not delete the unwanted records in sys_portal and sys_portal_preferences.

3 REPLIES 3

prashantkulkarn
Tera Contributor

Anyone knows solution for this?

MaxMixali
Kilo Sage

Hi, you can try this code manually: 

 

// Business Rule o Fix Script da eseguire in Production
// Inserisci i sys_id dei record da eliminare

var recordsToDelete = [
'sys_id_portal_1',
'sys_id_portal_2',
'sys_id_preference_1'
];

recordsToDelete.forEach(function(sysId) {
var gr = new GlideRecord('sys_portal');
if (gr.get(sysId)) {
gs.info('Deleting portal: ' + gr.getValue('title') + ' (' + sysId + ')');
gr.deleteRecord();
}

// Anche per sys_portal_preferences
gr = new GlideRecord('sys_portal_preferences');
if (gr.get(sysId)) {
gs.info('Deleting portal preference: ' + sysId);
gr.deleteRecord();
}
});

 

Seems helpful