Deleting records can be very slow, but the code below deletes them more quickly. By using the command setWorkFlow(false)
, you can turn off business rules, which speeds up the process.
ServiceNow advises administrators not to delete records because it is considered bad practice and can create broken links between tables. Instead, it is recommended to set the status of a record to “retired” or a similar value.
Deleting records in the Groups table is particularly slow because these records are synchronized with the MID Servers. Delete records in the Groups table can take 600ms per record. Apparently, each deletion causes the MID Servers to refresh their cache.
var grComputer = new GlideRecord("u_rtmodule_target");
grComputer.query();
grComputer.setWorkflow(false);
grComputer.deleteMultiple();
Leave a Reply