How to send email history with email option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2012 10:14 PM
As a part of IM process, we need to remind a user 2 times before closing an incident. When we use email option available on the incident form it only includes the current text. We wanted to include earlier emails as well and send the email trail to the user.
E.g. after first reminder is sent then while sending second reminder, email of first reminder should also be attached to it.
There is a simple way of copying pasting, however it gets added to 'Activity tracker' and is not user friendly.
Please help with it.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2013 12:52 PM
I got this to mostly work as a Client Template. It's really REALLY not an elegant solution, but it at least works (mostly).
The bit that I cannot get to work is setting the sys_id to document.location.getParameter('sysparm_sys_id').
If I set the sys_id variable to a known SYS ID, it works fine, but that isn't terribly dynamic, is it?
<mail_script>
//get the sys id of the refering task
var sys_id = document.location.getParameter('sysparm_sys_id');
// This is the example SYS ID I used with success.
//var sys_id = '54cc3872a0858d001433f8ee9e586dbb';
//create a glide record to query the sys_email table for emails sent about this job
var emailQuery = new GlideRecord('sys_email');
emailQuery.addQuery('instance', sys_id);
emailQuery.orderByDesc('sys_created_on');
emailQuery.query();
var qwer = '<hr>\n\n';
//bundle up the body text
while(emailQuery.next()){
qwer += 'From: ';
qwer += emailQuery.user;
qwer += '\n To: ';
qwer += emailQuery.recipients;
qwer += '\n Sent: ';
qwer += emailQuery.sys_created_on;
qwer += '\n\n Subject: ';
qwer += emailQuery.subject;
qwer += '\n\n';
qwer += emailQuery.body_text;
qwer += '<hr>\n\n';
}
template.print(qwer);
</mail_script>
When I run this as is, it returns a blank email with some blank lines. If I comment out line 5 and uncomment line 8, it works fine.
Can anyone help determine why this is failing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2013 01:19 PM
No sooner do I post an update here that a coworker swaggers over and fixes it for me.
var sys_id = current.sys_id;
Works like a charm!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 04:20 AM
Hi Tim,
Copied the code to the body section of the Email client template and the output is blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2013 01:24 PM
Happy you have found your solution tdeniston.