- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 07:36 AM
I have a requirement to attach a document to notification email but include attachment feature not working.
Basically, I need the attachment to show in the approval notification email the approver gets. In my workflow for requested items, I have a task where an itil user has to attach a document for review by the approver. when the task is closed, an approval request is generated. so when the approver gets the email, I want the attachment to show in the email. Most of the approvers are not itil users so they need to be able to see this in an email. tried the include attachment feature in notification but it doesn't work. pls see below. not great with scripting so need some assistance pls.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 09:46 PM
Hi,
If the attachment is uploaded on requested item, you don't need getTaskId(). I assume your notification is created on the Approvals table (sys_approval_approver). Change the following line in the above code and I think you should be all set.
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sysapproval.sys_id); // current.sysapproval field should have the requested item object.
gr.query();
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:02 AM
Hi Gbade,
You can include link to attachment so that once user visits the link it gets downloaded.
Following link will be helpful to you
http://wiki.servicenow.com/index.php?title=Include_Attachments_in_an_Email_Notification#gsc.tab=0
How to include attachments into email?
Add attachment to Notification Email
If you want to send the attachment explicitly then when you create an email notification there you will find a checkbox for Include attachments. check that box and all the attachments present for the record will be attached in email i.e if email triggers for INC2134 then all attachments for this INC will be sent
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
‎03-02-2017 08:25 AM
Hi,
You should add a notification email script in the notification message and the mail script should read the attachment table for the related task and display it as a link.
Create a notification email script with the code
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', getTaskId()); // Should be the sys_id of your Task where attachment is located
gr.query();
if (gr.next()) {
var attachLink = '<a href="' + gs.generateURL(gr.getTableName(),gr.sys_id) + '">' + gr.file_name + '</a>';
template.print(attachLink + "<br />");
}
function getTaskId(){
//Get the sys_id of your task by dot walking from approval record (current.sysapproval) to get the requested item and then the related task
// Or
// Pass it as a parameter if the email is triggered via event
}
Finally add the mail script in your notification Message field as ${mail_script:name_of_mail_script}
Please try hardcoding the task sys_id first for testing
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2019 06:38 PM
Hi A K,
Can you advise how this function works: How can I get the task ID where I need to get the attachment. Mine is similar but I do not use the RITM. I only have REQ and TASK as I use a record producer and not catalog item.
function getTaskId(){
//Get the sys_id of your task by dot walking from approval record (current.sysapproval) to get the requested item and then the related task
// Or
// Pass it as a parameter if the email is triggered via event
}
I need to get the attachments from one of the tasks {I have multiple tasks} where short description contains 'GREEN' and attach it on to the approval notification. Can you help.
Thanks,
Ramel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 10:38 AM
Thanks a lot, I'll give it a go. 🙂