Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This code_snippet.js script export incidents of the last 7 days and email the CSV.
This script will be created as Scheduled Script.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Below script export incidents of the last 7 days and email the CSV using Scheduled Script
var fileName = 'incident_export_' + gs.nowDateTime() + '.csv';
var csv = 'Number,Short Description,Priority\n';
var gr = new GlideRecord('incident');
gr.addQuery('opened_at', '>=', gs.daysAgoStart(7));
gr.query();
while (gr.next()) {
csv += gr.number + ',' + gr.short_description + ',' + gr.priority + '\n';
}
var attachment = new GlideSysAttachment();
attachment.write('incident', '', fileName, csv);
gs.eventQueue('csv.report.ready', null, fileName, gs.getUserID());
Loading