- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:05 AM
Hello!
I have a requirement to create an email notification where the email body contains the short description of the ticket. This short description will be a hyperlink to the ticket. Is this possible?
I am unable to use {URI_REF} because the the display shows the ticket number instead of the short description.
Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:08 AM - edited 07-24-2023 05:47 AM
Hi @ceraulo,
You need to construct the URL and add it to the notification using anchor tags in email scripts as follows:
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + current.getTableName() + '.do?sys_id=' + current.getUniqueValue() + '">' + current.short_description + '</a>';
template.print(url + "<br />");
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:08 AM - edited 07-24-2023 05:47 AM
Hi @ceraulo,
You need to construct the URL and add it to the notification using anchor tags in email scripts as follows:
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + current.getTableName() + '.do?sys_id=' + current.getUniqueValue() + '">' + current.short_description + '</a>';
template.print(url + "<br />");
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:33 AM
Hi @ceraulo ,
Hope you are doing great.
Create an email notification script to include the ticket's short description as a hyperlink:
// Step 1: Create a new email notification script
// This script fetches the short description and ticket number and includes it as a hyperlink in the email body
var shortDescription = current.short_description;
var ticketNumber = current.number;
var ticketLink = gs.getProperty('glide.servlet.uri') + current.getLink(true);
// Define the email body
var emailBody = "Hello,\n\n";
emailBody += "You have a new ticket: <a href='" + ticketLink + "'>" + shortDescription + "</a> (Ticket Number: " + ticketNumber + ").\n";
emailBody += "Please review the ticket for further action.\n\n";
emailBody += "Best regards,\nYour IT Team";
// Set the email body
email.setBody(emailBody);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:54 AM
@ceraulo Create a new email script "short_description_link" with the following script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var tbl = current.getTableName();
var sysID = current.sys_id;
var link = createLinkForObject(tbl, sysID, current.short_description);
template.print(link);
function createLinkForObject(strTableName, strSysID, short_description) {
return '<a href="' + gs.getProperty('glide.servlet.uri') + gs.generateURL(strTableName, strSysID) + '">'+short_description+'</a>';
}
})(current, template, email, email_action, event);
2. In the email notification replace ${URI_REF} with ${mail_script:short_description_link}
Please mark the appropriate response as correct answer and helpful.
Thanks!!