Email Script; help with a template.print statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 02:43 PM
Hi all,
I am trying my hand at html reporting via email notifications / scripts. I would like to enhance what I have so far, with including a hyperlink for the ticket number.
I have this template.print which works correctly, however, does not have a clickable number link:
template.print("<tr><td>" + gr.number + "</td><td>" + gd.getDisplayValue() + "</td><td>" + gr.short_description + "</td></tr>");
I found an example in another thread as below:
template.print("<a href='" + url + "'>" + current.number + "</a>");
This does not work when I try to combine with my existing statement
template.print("<tr><td> <a href='" + baseUrl + gr.getLink() + "'>" + gr.getValue('number') + "</a></td><td>" + gd.getDisplayValue() + "</td><td>" + gr.short_description + "</td></tr>");
I get a blank screen in the email preview, so I believe that my attempt above is off a little. Just after another set of eyes to see where I could be going wrong.
Cheers,
Brendan
- template.print("<a href='" + url + "'>" + current.number + "</a>");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 03:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 03:27 PM
Hi Michael,
The code you're suggesting would only return the current ticket number? I'm not sure that will work, as the script is referencing filtered data, as per Using Email Notifications as Custom Reports
Cheers,
Brendan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 03:32 PM
Yes, it returns the current ticket number. Works fine for us in Helsinki P7.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 03:40 PM
Hi Micahel,
Unfortunately, I cannot use it in this instance.
This is the mail script I am currently working with. The point of the mail script is to filter data and then display it in a html table.
var gr = new GlideRecord('task');
var gd = new GlideDate();
gd.setDisplayValue(gr.sys_created_on);
gr.addEncodedQuery("active=true^sys_class_name=sc_task^ORsys_class_name=incident^sys_created_onRELATIVELE@dayofweek@ago@60^assignment_group=5f6441efc0a8010e0177fcb589156352");
gr.query();
template.print('<table class="report-table"><tr class="tr"><th class="th">Number</th><th class="th">Opened</th><th class="th">Short Description</th></tr>');
while(gr.next()){
template.print("<tr><td> <a href='" + baseUrl + gr.getLink() + "'>" + gr.getValue('number') + "</a></td><td>" + gd.getDisplayValue() + "</td><td>" + gr.short_description + "</td></tr>");
}