
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 04:20 AM
Hi,
I need to clear the values from a field in a table (or set to 0) before I run the Import Set to update the data.
I have a table with different entries and stock values. I have also a import set to update the stock values with ne entries but in the update list are not all entries available. So my plan was to set all stock values to null before I run the import set, but I don ´t know how.
Thats why I need your help.
Best regards
André
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 04:27 AM
You can run the following script before your import:
var gr = new GlideRecord('your_table');
gr.addQuery();
gr.query();
while (gr.next()) {
gr.u_field_1 = 0;
gr.u_field_2 = 0;
gr.update();
}
If you have this import set scheduled, then you can include this code in "Execute pre-import script" section.
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 04:27 AM
You can run the following script before your import:
var gr = new GlideRecord('your_table');
gr.addQuery();
gr.query();
while (gr.next()) {
gr.u_field_1 = 0;
gr.u_field_2 = 0;
gr.update();
}
If you have this import set scheduled, then you can include this code in "Execute pre-import script" section.
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2019 01:11 PM
I can't quite make sense of this script but as commented it seems inefficient. Another post suggests this for a post cleanup:
var ic = new ImportSetCleaner();
ic._cleanTable(import_set.table_name, 'sys_import_set=' + import_set.sys_id);
Like the OP I want a pre cleanup so data is retained for troubleshooting. Unfortunately I don't speak SN so I'm unsure how to modify this seemingly simple command to do what is needed.