Automatically include attachments from TASK, on Email client , Client Template

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2019 09:13 AM
Hi all,
I've created a Client Template for the first time, to be used in the Email Client I've enabled on a custom app. End users pretty happy with what it's doing (Really like how easy it was to make the template) but they have asked is it possible for the template to automatically include as attachments, any attachments present on the Task itself?
I can't see any obvious option for this. So to re-iterate, a TASK is logged with attachments, our users then use the email client to email a third party. And they want the attachments on the TASK to appear on the template, so they dont have to download and re-attach.
I'm not seeing how I make the attachments present on the TASK, populate onto the mail. (The attachment you see is an img from a signature that is to appear on every outbound mail in this app)
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2019 09:56 AM
Hi ,
you can try something like this .
var grAttach=new GlideRecord('sys_attachment');
grAttach.addQuery('table_name','YOUR_TABLE_NAME');
grAttach.addQuery('table_sys_id','YOUR_RECORD_ID');
grAttach.query();
while(grAttach.next())
{
template.print ( 'Attachment: <a href="/sys_attachment.do?sys_id=' +grAttach. sys_id + '">' + gr. file_name + '</a>\n ' ) ;
}
this will bring all the attachments related to your record.
Thanks,
Mukesh Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2019 02:04 AM
Hi Mukesh,
Do I just drop that code into the body section of the template?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2024 07:40 AM
Just wondered if you ever found a solution for this, as years later...i'm in the same boat... if so please share! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2019 09:09 AM
Hi Daniel,
You have to write email client script and copy the code in that email client script . after that you can call that email client script in your template by writing .
${mail_script:script name}
to create email script click on 'notification email script' under system notification section .
Hope this was helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2019 09:58 AM
Think we are nearly there. Really appreciate your help, scripting isn't my strongest suit in ServiceNow
In your script
var grAttach=new GlideRecord('sys_attachment');
grAttach.addQuery('table_name','YOUR_TABLE_NAME');
grAttach.addQuery('table_sys_id','YOUR_RECORD_ID');
grAttach.query();
while(grAttach.next())
{
template.print ( 'Attachment: <a href="/sys_attachment.do?sys_id=' +grAttach. sys_id + '">' + gr. file_name + '</a>\n ' ) ;
}
You have "YOUR_RECORD_ID" I don't understand this part. If the record is going to be different every single time, how can I define the record id?
Or are you saying to define the sys id of the table there?