How to delete insert in import set

Mi1
Tera Contributor

Hi,

I'm using an import set.

I want to delete all the records in the table and insert them anew.

What kind of setup is possible?

Regards,

1 ACCEPTED SOLUTION

suvro
Mega Sage
Mega Sage

First delete all the records using background script. Then import the data

var delGr = new GlideRecord('table_name');

delGr.query();

delGr.deleteMultiple();

View solution in original post

9 REPLIES 9

Thanks. In that case you can try using Transform script as attached.find_real_file.png

Script as below. Update the Target table name accordingly for your case.

(function transformRow(source, target, map, log, isUpdate) {

	var deleterec=new GlideRecord('business_unit');//replace table name here
	deleterec.query();
	deleterec.deleteMultiple();

})(source, target, map, log, action==="update");

 

Mi1
Tera Contributor

Hi,

Thank you.

I tried, but only the last line was inserted.

Am I missing something?

Regards,

Mi1
Tera Contributor

Hi,

Thanks,

I was able to accomplish this with onStart in transform map!

Regards,

Hi,

 

You must be using a scheduled data import.

There you have option to Execute pre-import script check that checkbox you will get a editor to write your scripts. There you can execute this code.

var delGr = new GlideRecord('table_name');

delGr.query();

delGr.deleteMultiple();

Mi1
Tera Contributor

Hi,

Thanks, I was using JDBC File Loader.

Regards,