Generate a weekly incident report (CSV attachment) for incidents created during the one-week
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2025 07:56 AM - edited 10-18-2025 07:57 AM
Generate a weekly incident report (CSV attachment) for incidents created during the one-week window from last Friday 09:00 AM up to this Friday 09:00 AM, and email filtered attachments to recipients based on Category / Sub-category rules.
or incidents created within the date window, group and send attachments based on the following Category/Sub-category rules:
Category = Network AND Sub-category = DNS
Recipient: Abel Tuter (abel.tuter@yourcompany.com)
Category = Network AND Sub-category = VPN
Recipient: Fred Luddy (fred.luddy@yourcompany.com)
Category = Hardware AND Sub-category = CPU
Recipient: Deepa Shah (deepa.shah@yourcompany.com)
Notes: Each recipient should receive only the incidents that match their rule (i.e., one CSV per recipient containing only their matching records).
How we can acheive it. we dont want to use scheduled reports for this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2025 09:22 AM
Hi @Mannam Praveen ,
You can use Scheduled jobs & write a script to generate CSV file using below script.
You can also use Flow designer to run periodically.
var csv = [];
var headers = ['Number', 'Short Description', 'Category', 'Subcategory', 'Opened'];
csv.push(headers.join(','));
var gr = new GlideRecord('table_name');
gr.addQuery('Query');
gr.query();
while (gr.next()) {
var row = [];
row.push(gr.getValue('number'));
row.push('gr.getValue('short_description');
row.push(gr.getValue('category'));
row.push(gr.getValue('subcategory'));
row.push(gr.getValue('sys_created_on'));
csv.push(row.join(','));
}
var csvString = csv.join('\n');
var grFile = new GlideRecord('sys_attachment');
grFile.initialize();
var attachment = new GlideSysAttachment();
attachment.write('incident', '', 'incident_report.csv', csvString);
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards,
Madhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2025 08:18 PM
Thanks for script but how I can attach csv file notification and send through notification. Because here we have multiple conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2025 11:08 AM
Hi @Mannam Praveen ,
Using event you can pass it on to the notification & trigger it from there or if you're triggering from any record directly you can say include attachments & this attachment generated above will be used to send it.
In my case we're first attaching the attachment generated on RITM & changing the state using the same script so a notification will be triggered and automatically include our attachment added.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards,
Madhan
