diff --git a/Mail Scripts/Added a case/content b/Mail Scripts/Added a case/content new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Mail Scripts/Added a case/content @@ -0,0 +1 @@ + diff --git a/Mail Scripts/Case details/Case details notification.js b/Mail Scripts/Case details/Case details notification.js new file mode 100644 index 0000000000..24b3f69c30 --- /dev/null +++ b/Mail Scripts/Case details/Case details notification.js @@ -0,0 +1,81 @@ +(function runMailScript(current, email, email_action, event) { + // Store frequently used `current` values in variables to avoid multiple calls + var caseSysId = current.getValue('sys_id'); + var caseNumber = current.getValue('number'); + var caseLink = '' + caseNumber + ''; + + // Retrieve the first name from the event parameter, defaulting to "Team" if missing + var firstName = event.parm2 || "Team"; + + // Top banner HTML + var banner = + ''; + + // Initialize email body with banner + var emailBody = banner + + '
' + + '

Hello ' + firstName + ',

' + + 'You have been added to case ' + caseLink + '\'s watch list. Click the link to view the case details.

' + + ''; + + // Case record processing + var gr = new GlideRecord('sn_customerservice_case'); + if (gr.get(caseSysId)) { + // Using getValue() for fields to ensure direct string handling + emailBody += ''; + emailBody += ''; + + emailBody += ''; + emailBody += ''; + + // Retrieve attachments associated with the case + var attachmentGr = new GlideRecord('sys_attachment'); + attachmentGr.addQuery('table_sys_id', caseSysId); + attachmentGr.query(); + + // Attachments section + if (attachmentGr.hasNext()) { + emailBody += ''; + emailBody += ''; + } else { + emailBody += ''; + } + } else { + emailBody += ''; + } + + // Closing the table and email body + emailBody += '
Description:' + gr.getValue('description') + '
Location:' + gr.getDisplayValue('location') + '
Images:'; + + while (attachmentGr.next()) { + var attachmentLink = gs.getProperty('glide.servlet.uri') + 'sys_attachment.do?sys_id=' + attachmentGr.getValue('sys_id'); + var fileName = attachmentGr.getValue('file_name'); + + // Display image if applicable, otherwise show a link + if (attachmentGr.getValue('content_type').startsWith('image/')) { + emailBody += '

' + fileName + '

'; + } else { + emailBody += '

' + fileName + '

'; + } + } + emailBody += '
No attachments found for this case.
No matching case details found.
'; + emailBody += '

Best regards,
(name)

'; + emailBody += '
'; + + // Bottom Banner HTML + var bottombanner = + '
'; + + // Append bottom banner to the email body + emailBody += bottombanner; + + // Output the email body + template.print(emailBody); + +})(current, email, email_action, event); diff --git a/Mail Scripts/Case details/Readme.md b/Mail Scripts/Case details/Readme.md new file mode 100644 index 0000000000..1b08087d07 --- /dev/null +++ b/Mail Scripts/Case details/Readme.md @@ -0,0 +1,9 @@ +Scenario: You are wanting to send a notification that contains: a link to a case, case details such as description and location, and any attachments on the case. + +Application: Create a mail script and set the name "Added to case" (replace with desired name). Create a notification, set the name, and table. + +When to send: +Choose the conditions. + +What it will contain: +"mail_script:added_to_case". // Mail_script:(replace with mail script name) \ No newline at end of file