Assistance with sending a link in the request notification

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2023 02:58 PM
I'd like to do two things that currently I don't seem to be able to workout:
- Add a link in the email notification to any request item within the request and it's short description
- Add details of the request items to the notification eg: the variables and their values
All we currently have is a link to the request, however there is no information obviously in the request ticket and we want to allow our staff to click on a link and be taken directly to the information, rather needing them to figure out how to get to the information.
I've looked at the info available on creating links, but I really have no idea how to add anything to our current notification:
Email Script:
Name: add RITM variables
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sysapproval.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getDisplayValue() != '' && +vs.get(i).getLabel() != '') {
template.space("\n");
template.print("\n" + "<br>" + vs.get(i).getLabel() + ": " + vs.get(i).getDisplayValue() + "\n" + "</br>");
}
}
})(current, template, email, email_action, event);
Email script:
Name: take_me_to_ticket_button
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var type = current.sys_class_name; // grab the table name.
var urlPrefix;
// Logic to ensure the URL points to the DNS CNAME rather than the actual instance name.
if (gs.getProperty('glide.servlet.uri').includes("prod")){
urlPrefix = gs.getProperty('DNS.Prod');
}
if (gs.getProperty('glide.servlet.uri').includes("test")){
urlPrefix = gs.getProperty('DNS.Test');
}
if (gs.getProperty('glide.servlet.uri').includes("dev")){
urlPrefix = gs.getProperty('DNS.Dev');
}
var link_frontEnd = urlPrefix + '/sp?id=ticket&table=' + type + '&sys_id=' + current.sys_id;
var link_backEnd = current.getLink().replace(/https.*com.au/, urlPrefix);
template.print('<font face="helvetica">');
var backgroundColor = 'background-color: #278efc;';
var border = 'border: 1px solid #ffffff;';
var color = 'color: #ffffff;';
var fontSize = 'font-size: 16px;';
var fontFamily = 'font-family: Calibri, sans-serif;';
var textDecoration = 'text-decoration: none; border-radius: 3px;';
var webKitBorder = '-webkit-border-radius: 3px;';
var mozBorder = '-moz-border-radius: 3px;';
var display = 'display: inline-block;';
var padding = 'padding: 5px;';
// gs.log ("*** Email notification for table: " +type);
if (type == 'incident' || type == 'current.request_item') {
template.print('<a href="' + link_frontEnd + '"');
} else {
template.print('<a href="' + link_backEnd + '"');
}
template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + +webKitBorder + mozBorder +display + padding);
template.print('">');
template.print(gs.getMessage('Take me to the Ticket'));
template.print('</a>');
template.print('</font>');
template.print('<br>');
template.print('<p><font size="3" color="#808080" face="helvetica">');
template.print('</font></p>');
})(current, template, email, email_action, event);
0 REPLIES 0