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.

Deleting multiple domain records

Mrigank Gupta1
ServiceNow Employee
ServiceNow Employee

Deleting domain records is a slow process where it trigger domain hierarchy job everytime.

Is there a way to quickly delete all the domains from the domain table?

1 REPLY 1

Alex Tod1
Kilo Sage

Hi @Mrigank Gupta1!,

  I don't know much about the domain module, but have you tried to delete it with a fix script? It might be very risky to do this because the delete has a property of cascading and you could delete all related table records.

var domainTable = 'cmn_domain'; // Adjust the table name if needed

// Create a GlideRecord query to get all domain records
var domainRecords = new GlideRecord(domainTable);
domainRecords.query();

// Delete each domain record
while (domainRecords.next()) {
    domainRecords.deleteRecord();
}

gs.info('Deleted all domain records from ' + domainTable);