Attaching a CSV File to a Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 10:35 AM
I am currently working on a script action in ServiceNow where I generate a CSV file. My goal is to attach this CSV file to a notification in the "sysevent_email_action" table. Is it possible to attach the CSV file from the script action to the notification? If so, could you provide any insights or steps on how this can be done efficiently? Any guidance would be greatly appreciated! Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 01:00 PM
I'm not sure I understand why you would want to generate a CSV to add to a notification record. Are you wanting it to be added to the email that is sent? Is that the goal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 12:19 AM - edited ‎01-09-2025 12:22 AM
Yes, exactly, that is the goal! 🙂 The CSV file is generated in the script action, and now I want to send it via a notification. A colleague of mine generated the CSV in the script action and created the email directly from the script action. However, I want to handle sending the email through a notification instead.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 05:00 AM
I think you will want to add it to the sys_email_attachment table. I have a business rule that runs on the sys_email_log table and has a condition to narrow it to specific emails. Then it adds an attachment to that email like this:
var att = new GlideRecord('sys_email_attachment');
att.initialize();
att.attachment = gr.sys_id; //In my case, this links to a specific attachment in the sys_attachment table
att.content_disposition = "attachment";
att.action = 'attached_to_target_record';
att.email = current.email;
att.insert();
Now, my code adds an attachment that's already uploaded into the sys_attachment table. Since you are generating yours dynamically, the code will be slightly different, but hopefully that gets you started.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 05:30 AM
Ideally that file needs to be attached to the target record on which notification is being sent.
Then when you use Include attachment checkbox that file will be sent over via email
what's your business requirement?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader