Copying Attachment from Scheduled E-mail of report to a newly created record in another table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2025 01:24 PM
Hello good People,
I have requirement which I will explain briefly.
Requirement:
- In our instance we have a scheduled email of report, that is attaching one report to the email.
- The requirement is to create a ticket on sc_task table with the same attachment.
The obvious plain solution is to write a business rule on the email logs table to create a record and copy the attachment[ which is not preferrable to do]
Create an inbound action which will add the attachment to the record.
Are there any other good possible ways to meet this requirement.
Please comment your ideas, I really appreciate them.\
thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2025 01:26 PM - edited ‎07-27-2025 01:27 PM
Hi @SunnyDi
Try Scheduled Script
Instead of relying on email logs or inbound actions, you can write a Scheduled Script Execution (Scheduled Job) that:
- Queries the scheduled report execution logs (or sys_email if needed)
- Locates the generated report attachment (sys_attachment)
- Creates the sc_task record
- Copies the attachment to the task (you can use GlideSysAttachment.copy())
var reportGr = new GlideRecord('sys_report');
if (reportGr.get('<REPORT_SYS_ID>')) {
// Create a new SC Task
var task = new GlideRecord('sc_task');
task.initialize();
task.short_description = 'Report attached: ' + reportGr.name;
task.insert();
// Copy attachments
var attachment = new GlideSysAttachment();
attachment.copy('sys_report', reportGr.sys_id, 'sc_task', task.sys_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2025 08:22 PM
you can create after insert business rule on sys_attachment table and determine the table and the table_sys_id of that of scheduled report, from there you can create sc_task and copy attachment.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader