Export set condition

KB15
Giga Guru

I'm trying out the export set feature with the scheduled export option. I've noticed that it will continually export data whether or not there's new or changed data. This leaves me with a whole bunch of empty CSV files.

This is my conditional script to list any records created after the "last run" field from the scheduled export but I'm not sure if I can reference the last run field properly.

var gr = new GlideRecord('u_export_table');

gr.addEncodedQuery('sys_created_on>=javascript:gs.dateGenerate'+ '(' + current.last_export_run + ')');

gr.query();

if(gr.getRowCount() < 0){

        cancel = true;

}

find_real_file.png

3 REPLIES 3

Alikutty A
Tera Sage

Hi Kim,



Please try this code



var gr = new GlideRecord('u_export_table');


gr.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('"+current.last_export_run +"')");


gr.query();



if(gr.getRowCount() < 0){


  cancel = true;


}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


I don't think that's quite right. I also realized the cancel = true option isn't available in the condition field. I think it'd be just a true or false option, which I've tried already.


Community Alums
Not applicable

This worked for me.

Write this inside conditions box,

var gr = new GlideRecord('u_lenovo_laptop_bundle');
gr.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('"+current.last_export_run.getDisplayValue()+"')");
gr.query();
gs.log('Found ' + gr.getRowCount() + ' records');
if(gr.getRowCount() < 1){	
	answer = false; // Do not export
}
else{	
	answer = true; // Do the export
}

 

Thanks,

Rajini