The CreatorCon Call for Content is officially open! Get started here.

Cancel scheduled export if no new records

Antti Luusua
Kilo Guru

Hello,

is it possible to cancel a scheduled export of data if there are no new records after last export run (delta)

 

I tried searching and found a couple of proposed solutions, for example https://community.servicenow.com/community?id=community_blog&sys_id=28165260db8098d823f4a345ca9619e2 but this does not seem to work. Scheduled export produces empty files if there are no new records.

 

In scheduled reports there is the option to omit if no new records but such functionality doesn't seem to exist in scheduled exports.


I am exporting incidents with specific conditions.

Thank you!

4 REPLIES 4

suvro
Mega Sage

Use these objects in scheduled export set scripts, such as the Pre-script and Post-script fields.

cancel
Set this object to true to stop the export action. Any child export sets are also cancelled if the parent is cancelled. This object is available only in the Pre-script field.
Example: Use the Pre-script field to evaluate the conditions of the export and determine whether to cancel the export process. To cancel the export process, use the following call:
cancel = true;

Thank you suvro.

 

I found the same official ServiceNow documentation about cancel object but I am not sure how to use it in pre-export script. How can I query if export row count is zero or null? Ideally the script would be something like below but I don't know how to accomplish that.

// Get export set row count

if(row_set_count == 0) {
cancel = true;
}

Basically whatever data the report is showing ---> using Gliderecord find out whether that data exists ...if not return false in condition

There is also a check box omit if no records

find_real_file.png

Hi,

I am dealing with scheduled exports, not scheduled e-mail reports. I guess the principal is the same but I unfortunately have no idea how to script that in Javascript. 

 

How would I check if there are new records after last run export timestamp?