Cancel scheduled export if no new records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 04:53 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 05:01 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 05:04 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 05:22 AM
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?