Notifications - User Story 03
Title : Automated Notification Email on Ticket Resolution
Description:
As a requester of an IT Service Desk ticket, I want to receive a notification email when my ticket is resolved so that I am informed about the resolution of my request.
Acceptance Criteria:
When a ticket is resolved, an email notification should be sent to the requester, assigned to user, members of watchlist, and the members of the assignment group.
The subject of the email should follow the format: "Ticket [Ticket Number] - Resolved".
The body of the email should contain the following information:
To: Requester,
CC: Assigned to, Watchlist Users, Members of Assignment group
Subject: Ticket: [Ticket Number] - Resolved
Body:
Hi [Requester] / All,
The following ticket has been resolved. Please review the details: [Ticket Number as Link]
Ticket: [Ticket Number]
Short Description: [Short Description]
Created on: [Created Date]
Created by: [Creator]
Please check the [Link] for more details.
Thanks,
IT Support
Devlopment Plan:
Create one Notification on target table.
Create Email Script to add Email IDs in CC.
Add Email Script to the Notification newly created.
Devlopment Steps:
Go to Table list where you need to create Notification. Here, i am using my newly created table: "IT Service Desks".
Open any record > Right click on form banner > go to Configure > Notifications.
Click New, and provide the below details in Notification form to create new Notification.
Name : Notification on Ticket Resolution
Table : IT Service Desk // Provide your table name here
When to Send:
Send when : Record inserted or updated.
Updated : True
Conditions : When Field: 'State' value is 'Resolved' < State is Resolved >
Who will receive:
Users/Groups in fields : Requester, <Here, select required fields from field list>
What it will contain:
Subject : Ticket: ${number} - Resolved <Here, replace 'number' with your field name.>
Message HTML : <Here, provide the below details, and replace field names with your table field names.>
Hi ${u_requester} / All,
The following ticket has been resolved. Please review the details: ${REF}
Ticket: ${number}
Short Description: ${short_description}
Created on: ${sys_created_on}
Created by: ${u_requester}
Please check the ${URI} for more details.
Thanks,
IT Support
${mail_script:ScriptName}
To add CC : To add email address list in mail CC, here in above Message HTML field, along with mail body, at the end of mail body, we need to add a line to call Email Script. This Email Script will help to add mail IDs list to mail CC while sending mail notification. Follow "Steps to create Email Script" from the below. (ex: ${mail_script: Add_Email_IDs_in_CC} ).
Click on Save (Right click on form banner, then click on Save option to save the Notification).
Steps to create Email Script:
Navigate to All ==> System Notification ==> Email ==> Notification Email Scripts
Click New, and provide the below details in form to create new Email Script.
Name : Add_Email_IDs_in_CC
Script : <Place the below script in script section>
// Add the email address and display name of the user who submitted the issue to the "cc" field
email.addAddress("cc", current.u_issue_submitted_by.email, current.u_issue_submitted_by.user_name);
// Check if Additional POC's are provided
if (!current.u_additional_pocs.nil()) {
// Create a GlideRecord object to query the sys_user table
var user = new GlideRecord('sys_user');
// Add a query condition to filter user records by Additional POCs sys_id
user.addQuery('sys_id', 'IN', current.u_additional_pocs);
// Add a query condition to filter out user records without an email address
user.addQuery('email', '!=', '');
// Execute the query
user.query();
// Iterate over each user record that matches the query conditions
while (user.next()) {
// Add the email address and display name of each user to the "cc" field
email.addAddress('cc', user.email, user.getDisplayValue());
}
}
Here in above script, Update the field names u_issue_submitted_by and u_additional_pocs with your table field names.
Click Save. Now Email script is created and ready to use in Notifications.
Update the 'Message HTML' field under 'What it will contain' section in Notification newly created above with email script information. Ex: ${mail_script: Add_Email_IDs_in_CC}
Click on Save (Right click on form banner, then click on Save option to save the Notification).
Click on "Preview Notification" Button to see the preview of notification which we created now with above steps.
Step by step screenshots: