- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2022 11:56 PM
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,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:01 AM
First delete all the records using background script. Then import the data
var delGr = new GlideRecord('table_name');
delGr.query();
delGr.deleteMultiple();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 12:45 AM
Thanks. In that case you can try using Transform script as attached.
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");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 01:06 AM
Hi,
Thank you.
I tried, but only the last line was inserted.
Am I missing something?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 01:20 AM
Hi,
Thanks,
I was able to accomplish this with onStart in transform map!
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 01:13 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 01:20 AM
Hi,
Thanks, I was using JDBC File Loader.
Regards,