- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 06:52 AM
During the night our system import various data sources, but if something went wrong on the side of, for example, a SQL server where data is being imported from, it might occur that an empty Import Set is created.
But this import set gets transformed nonetheless, and with me having onStart transform actions which sets records to inactive followed by a onComplete transform which deletes all inactive records, I end up with empty tables in the morning...
To prevent this I was thinking along the lines of checking if the Source or Import set in the onStart transform script has records and if not sending an ignore=true.
But I can't seem to find an easy way to get the rowcount of the Importset...
Any ideas?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 07:05 AM
Use this in the onstart script
var gr= new GlideRecord('sys_import_set_row');
gr.addQuery('sys_import_set',import_set.getValue('sys_id'));
gr.query();
if(gr.getRowCount()==0){
ignore=true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 07:05 AM
Use this in the onstart script
var gr= new GlideRecord('sys_import_set_row');
gr.addQuery('sys_import_set',import_set.getValue('sys_id'));
gr.query();
if(gr.getRowCount()==0){
ignore=true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 07:26 AM
Thanks that works.
I just finished my variant on this:
var gris = new GlideRecord(import_set.table_name);
gris.addQuery('sys_import_set', import_set.sys_id);
gris.query();
if (gris.getRowCount() == 0) {
ignore = true;
}
sys_import_set_row or import_set.table_name, has the same result, what's the better choice?
Luckily it also prevents onStart scripts with an higher order, so it promptly stops importing
Was looking for a variable or function on the Source or import_set, but I guess using 1 GlideRecord can't hurt either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2016 07:49 AM
yes importset.table_name is much cleaner and more dynamic.