Is it possible to delete existing data as part of an import set

Peter Bishop
Kilo Expert

I have an import set working to populate a table from an external source. However the import is cumulative so that running the same file twice results in twice the records in the target table.

Is it possible to clear the target table prior to performing the import?

Thanks.

6 REPLIES 6

Siddartha Gudim
Tera Guru

You can make use of colease function in case if you have unique field for the update.



For the existing duplicate records make use of background script to delete the duplicate record and have the latest one in the table.




Mark helpful or correct based on the impact of the response.


Gowrisankar Sat
Tera Guru

If you are using transform scripts, this link should be helpful:



Cleaning up transformed rows right after transform completion


Thanks. Gave me the in I needed. Created a transform script (below) and it worked like a dream:


(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {


      var gr = new GlideRecord("u_targettable");


      gr.query();


      gr.deleteMultiple();


})(source, map, log, target);


Dave Smith1
ServiceNow Employee
ServiceNow Employee

Is it possible to clear the target table prior to performing the import?


Yes - but this really means you're scrubbing and rebuilding records, rather than appending/updating existing ones.



There's increased processing overhead with your "greedy approach", rather than looking at the "minimal effort approach", which is coalescing during transformation.



As a matter of interest, could you benefit from a direct data connection to tweak records remotely, rather than bulk delete/inserts to keep data in sync?