|
| 1 | +1. Overview |
| 2 | +This mail script is designed for use in ServiceNow notifications. It dynamically generates an HTML structure that displays key record details (Short Description, Description, and Comments) in a visually appealing format. The script can be used in any ServiceNow notification to provide recipients with a clear, styled summary of the record's information. |
| 3 | + |
| 4 | +2. How It Works |
| 5 | +Key Fields: |
| 6 | + |
| 7 | +Short Description: Retrieves and displays the record’s short description. |
| 8 | +Description: Retrieves the full description of the record, preserving white spaces and line breaks. |
| 9 | +Comments: Retrieves the comments added to the record. |
| 10 | + |
| 11 | +The content is wrapped inside a <div> container, with styling applied using the HTML <font> tag to set the font size, bold text, and color. |
| 12 | +The use of gs.getMessage() allows for internationalization, ensuring that the script works well in multi-language environments. |
| 13 | +3. Steps to Implement |
| 14 | +Create a Notification: |
| 15 | + |
| 16 | +Navigate to System Notification > Email > Notifications in ServiceNow. |
| 17 | +Create a new notification or edit an existing one based on your requirements. |
| 18 | +Insert the Mail Script: |
| 19 | + |
| 20 | +In the notification, go to the Message tab. |
| 21 | +Use the Mail Script type to call the script in your notification message. |
| 22 | +The script will dynamically pull the details from the current record (such as incident or task). |
| 23 | +Adjust the Script: |
| 24 | + |
| 25 | +If needed, modify the script to display other fields or refine the content (e.g., fetching only specific journal comments). |
| 26 | +You can add additional fields like Priority, Assigned to, or custom fields using a similar method. |
| 27 | +4. Testing the Script |
| 28 | +Send a Test Email: |
| 29 | + |
| 30 | +After configuring the notification, trigger the event to send a test email. |
| 31 | +Ensure the email is formatted correctly and that the Short Description, Description, and Comments are displayed as expected. |
| 32 | +Positive Test Case: |
| 33 | + |
| 34 | +Create or update a record that matches the notification conditions. |
| 35 | +Verify that the email contains the correct record details in the styled format. |
| 36 | +Negative Test Case: |
| 37 | + |
| 38 | +Ensure that if no comments or description are available, the script does not throw errors but handles the empty fields gracefully. |
| 39 | +5. Benefits |
| 40 | +Improved Formatting: The use of HTML ensures that the notification looks professional, with clear headings and properly formatted text. |
| 41 | +Dynamic Content: The script automatically pulls data from the record, reducing manual intervention and the risk of errors. |
| 42 | +Internationalization: The use of gs.getMessage() allows for easy translation and localization of the content, making the script adaptable to global implementations. |
| 43 | +Reusability: This script can be reused across multiple notifications and customized easily to include additional fields or change the format. |
| 44 | +This approach enhances the quality of ServiceNow notifications, providing clear and well-structured information to end users. |
0 commit comments