- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2020 07:28 AM
Hi All,
I need to send the attachments uploaded on a particular catalog task, as file attachments to the Approver.
Can anyone please help me to identify the exact task attachment from the sys_attachment table?
Any help would be appreciated.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2020 07:43 AM
Hi,
Sample email script if your email notification is on sysapproval_approver table
And you want to show sc_task attachment
Email Script:
Name:show_attachments_task_record
Script:
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
// get attachment for all SC Tasks belonging to the RITM present for this Approval Record
var sc_taskRecord = new GlideRecord('sc_task');
sc_taskRecord.addQuery('request_item', current.sysapproval);
sc_taskRecord.query();
while(sc_taskRecord.next()){
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', sc_taskRecord.getUniqueValue());
gr.query();
if (gr.hasNext()) {
template.print("Attachments: <br />");
while (gr.next()) {
var url = gr.getTableName() + ".do?sys_id=" + gr.getValue('sys_id');
var attachLink = '<a href="' + url + '">' + gr.file_name + '</a>';
template.print(attachLink + "<br />");
}
template.print("<hr/>");
}
}
})(current, template, email, email_action, event);
Include in your notification like this ${mail_script:show_attachments_task_record}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2020 01:40 AM
Hi Ankur
Thank you very much for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2020 02:43 AM
You are welcome
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 12:22 AM
Hi Ankur,
I have a scenario where in task 1 candidate will upload attachment on sn_hr_core_task and there is another task 2 on sn_hr_core_task and once this is inserted I have to send an email with attachment submitted by candidate on task 1 to manager. How to achieve this Could you please help me.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 12:25 AM
2 ways
1) copy file to other task and include that file in email
OR
2) include link to that file and user will have to login to instance to download the file
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader