- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2020 12:35 AM
Hi All,
We have configured like when any additional comments added to the case it will sent mails to users in watch list. If any work notes added to the case it will sent mails to users in the work notes list. So in the notification selected "include attachment option".
All the attachment is attaching every time when any mail sent for additional comments or work notes added. How to include only latest updated attachments in the mail?
Please suggest
Regards,
Sruthi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2020 02:04 AM
you cannot include single attachment using the Include Attachment checkbox
you will have to uncheck that and include the attachment link in the email
Use email script to get the latest attachment link and use that email script in the notification
Email Script:
Name - show_specific_attachment
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord('sys_attachment');
gr.orderByDesc('sys_creatd_on'); //sort with created descending
gr.addQuery('table_sys_id', current.sys_id);
gr.setLimit(1); // pick only 1 attachment record
gr.query();
if (gr.hasNext()) {
template.print("Attachment: <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);
In notification include the email script as below
${mail_script:show_specific_attachment}
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
‎08-27-2020 03:09 AM
Hi Ankur,
Thanks for the Response.
Is there any option not to sent attachment which is already sent?
How to get recently attached all attachments If the agent attach 1 or more attachments same time?
Please suggest
Regards,
Sruthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2020 08:00 AM
the above script will include only 1 latest attachment link in email body
what is the criteria to know which attachment is latest? also you cannot determine which attachment was sent previously
to track that you will have to create custom field on your table to store which attachment was included last time when email triggered for this record.
you can then exclude that file name in your email script query so that it doesn't include that attachment link
Example: created on today or created on this week etc
Based on that query can be applied for sys_attachment
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
‎09-01-2020 10:14 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
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
‎09-04-2020 08:23 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
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
‎09-16-2020 07:38 AM
Hope you are doing good.
Glad to know that my response helped you.
Let me know if I have answered your question.
If so, please mark appropriate answer as correct & helpful to close the thread.
If not, please let us know if you need some more assistance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader