Skip to content

Commit b0179cd

Browse files
Create mail:script
This mail:script is a response for a case. It provides a link to the case and embeds the location, description and any attachments within that case. This can be used in a notification when an update on a case has occurred.
1 parent 27c22ba commit b0179cd

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

Notifications/mail:script

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Top Banner
2+
var banner =
3+
'<div class="banner" style="background-color: #000000; color: white; padding-top: 0px; padding-left: 10px; text-align: left; border-bottom: 5px solid gold; border-radius: 5px;">' +
4+
'<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt;">' +
5+
'<a title="<POP UP NAME>" href="<website>">' +
6+
'<img src="<image name in the instance>" width="168" height="56" />' +
7+
'</a>' +
8+
'</span>' +
9+
'</div>';
10+
11+
var emailBody = banner;
12+
13+
emailBody += '<div style="font-family: Arial, sans-serif; font-size: 16px; color: black;">';
14+
emailBody += '<p>Team,<br><br>';
15+
emailBody += 'New attachments have been added to case ' + caseLink + '. Click the link to view the case details.</p>';
16+
emailBody += '<table style="width: 100%;">';
17+
18+
emailBody += '<tr>';
19+
emailBody += '<td style="width: 120px; padding-left: 20px; padding-right: 0px; font-weight: bold; text-align: left;">Description:</td>';
20+
emailBody += '<td style="padding-left: 0px;">' + current.description + '</td></tr>';
21+
22+
emailBody += '<tr>';
23+
emailBody += '<td style="width: 120px; padding-left: 20px; padding-right: 0px; font-weight: bold; text-align: left;">Location:</td>';
24+
emailBody += '<td style="padding-left: 0px;">' + current.location.getDisplayValue() + '</td></tr>';
25+
26+
// Query the attachments
27+
var attachmentGr = new GlideRecord('sys_attachment');
28+
attachmentGr.addQuery('table_sys_id', current.sys_id);
29+
attachmentGr.query();
30+
31+
if (attachmentGr.hasNext()) {
32+
emailBody += '<tr>';
33+
emailBody += '<td style="width: 120px; padding-left: 20px; padding-right: 0px; font-weight: bold; text-align: top; vertical-align: top;">Attachments:</td>';
34+
emailBody += '<td style="padding-left: 0px;">';
35+
36+
while (attachmentGr.next()) {
37+
var attachmentLink = gs.getProperty('glide.servlet.uri') + 'sys_attachment.do?sys_id=' + attachmentGr.sys_id;
38+
var fileName = attachmentGr.file_name;
39+
40+
// Check if the file is an image
41+
if (attachmentGr.content_type.startsWith('image/')) {
42+
emailBody += '<p style="margin-bottom: 10px;"><img src="' + attachmentLink + '" alt="' + fileName + '" style="max-width: 400px;"></p>';
43+
} else {
44+
emailBody += '<p><a href="' + attachmentLink + '" target="_blank">' + fileName + '</a></p>';
45+
}
46+
}
47+
48+
emailBody += '</td></tr>';
49+
} else {
50+
emailBody += '<tr><td colspan="2" style="padding-left: 20px;"><b>No attachments found for this case.</b></td></tr>';
51+
}
52+
53+
emailBody += '</table>';
54+
emailBody += '<p>Best regards,<br><NAME></p>';
55+
emailBody += '</div>';
56+
57+
// Bottom banner
58+
var bottombanner =
59+
'<div class="bottom-banner" style="' +
60+
'background-color: #000000;' +
61+
'height: 10px;' +
62+
'border-top: 4px solid gold;' +
63+
'border-radius: 5px;' +
64+
'margin-top: 20px;' +
65+
'"></div>';
66+
67+
// Add the bottom banner to the email body
68+
emailBody += bottombanner;
69+
70+
'</div>';
71+
72+
template.print(emailBody);
73+
74+
})();

0 commit comments

Comments
 (0)