Notifications - User Story 04
Title : Weekly Reminder Notifications for Open Tickets
Description:
Weekly reminder notification emails need to be sent to the assigned technician and copied to users on the Watchlist, as well as the requester for visibility purposes.
Acceptance Criteria:
Weekly reminder notification should be sent for Open tickets, to the assigned to user, requester, members of watchlist, and the members of the assignment group.
The subject of the email should follow the format: "Ticket [Ticket Number] - Open/Overdue".
The body of the email should contain the following information:
To: Assigned to,
CC: Requester, Watchlist Users, Members of Assignment group
Subject: Ticket: [Ticket Number] - Open/Overdue
Body:
Hi [Assigned to] / 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.
Create Flow to trigger Notification on Scheduled Timings.
Devlopment Steps:
Steps to Create Notification:
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 : Weekly Reminder Notifications
Table : IT Service Desk // Provide your table name here
When to Send:
Send when : Triggered
Who will receive:
Users/Groups in fields : Assigned to, <Here, select required fields from field list>
What it will contain:
Subject : Ticket: ${number} - Open/Overdue <Here, replace 'number' with your field name.>
Message HTML : <Here, provide the below details, and replace field names with your table field names.>
Hi ${assigned_to} / All,
The following ticket is in Open/Overdue. 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.
Add Email Script to the Notification:
Open the newly created Notification with above mentioned steps.
Update the 'Message HTML' field under 'What it will contain' section in Notification 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.
Steps to create Flow:
Navigate to All ==> Process Automation ==> Click on 'Flow Designer'
Now we can see the Flow Designer will be opened in new tab with the name of Workflow studio.
Click on 'New' ==> 'Flow' to create new flow.
Give Flow Name and click on 'Build Flow'
Flow Name : Weekly Reminder Notification
Now we can see, new Flow created and opened.
Now, under TRIGGER section, click on 'Add Trigger' and provide below details (To schedule the flow on weekly basis).
Trigger : Weekly
Day of Week : Monday
Time : 10 (In hours field)
Click on Done.
Note: Here we are scheduling the flow to run on every Monday 10 AM.
Now, under ACTIONS section, click on 'Add an Action, Flow Logic, or Subflow'.
Click on Action ==> ServiceNow Core ==> Look Up Records, and provide the below details.
Action : Lookup Records
Table : IT Service Desk [u_it_service_desk] // Here, select your table
Conditions : State is one of New, In-Progress, Hold // Here select the condition
Click on Done.
Now, click on 'Add an Action, Flow Logic, or Subflow' ==> Flow logic ==> For Each.
Click 'Data Pill Picker for Items' of field 'Items' and press down arrow and select '1-Look Up Records', now press right arrow and select 'IT Service Desk Records' (Here you will see your table name). Refer the screenshots mentioned below for more details if required.
Now, click on 'Add an Action, Flow Logic, or Subflow' ==> Action ==> ServiceNow Core ==> Send Notification. Provide the below steps.
Click 'Data Pill Picker for Items' of field 'Record' and press down arrow and select '2-For Each-', now press right arrow and select 'IT Service Desk Record' (Here you will see your table name). Refer the screenshots mentioned below for more details if required.
Now, for field 'Notification', select name which created with above mentioned steps. Here i have selected as 'Weekly Reminder Notifications'.
Click Done.
Now, Click Save to save the Flow.
Click Test to test the Flow.
Click Activate to activate the Flow.
Step by step screenshots:
Step by step screenshots for Flow: