Can we undo an xml import via script

dhirajw27
Kilo Contributor

Is there any script to undo an xml import instead of manually deleting records ?

4 REPLIES 4

snehabinani26
Tera Guru

Hi Dhiraj,



Are you aware of the sys_id and table name where you have the import done.



Run this in background script


var gr = new GlideRecord("table_name");


gr.get(sys_id);


gr.setWorkflow(false);


gr.deleteRecord();



Hope this helps


How do you know which records were inserted, vs which were there previously?


No i am trying to buld a functionality where the last xml import that was done can be un-done on click of a button or so..


Thing about an XML import is its not necessarily an insert.   Records can be updated via the import as well.   So there's no "undo" unless you have some place that stores a snapshot of the data immediately before the import.   Another concern is updates that happened after the XML import: how do you propose to deal with them?