I want to set up an notification like around 5 tickets got assigned to my group in 15 min interval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 06:47 AM - edited 06-18-2023 06:50 PM
Hi Experts
I want to set up an notification like around 5 incident tickets got assigned to my group in 15 min interval.
Thank in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 01:38 AM
Hi @dhineshkumar
Do you need to get email notifications whenever tickets gets assigned to your group?Was it not following OOTB notifications?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 03:53 AM
Hi @dhineshkumar ,
Hope you are doing great.
to set up a notification for incident tickets assigned to your group within a 15-minute interval, you can follow these steps:
Create a Business Rule that runs whenever an incident ticket is assigned to your group. This rule will trigger the notification logic.
Define the Notification Condition: In the business rule, specify the condition that checks if the ticket is assigned to your group.
Implement the Notification Logic: Within the business rule, write the code to count the number of incident tickets assigned to your group within the last 15 minutes. Here's an example using ServiceNow GlideRecord API:
var currentTime = new GlideDateTime(); // Get the current time
var fifteenMinutesAgo = new GlideDateTime(currentTime);
fifteenMinutesAgo.addMinutes(-15); // Subtract 15 minutes from the current time
var gr = new GlideRecord('incident'); // Replace 'incident' with the table name of your incident ticket
gr.addQuery('assignment_group', 'your_group_id'); // Replace 'your_group_id' with the identifier of your group
gr.addQuery('sys_created_on', '>', fifteenMinutesAgo); // Filter tickets created within the last 15 minutes
gr.addQuery('sys_created_by', '!=', 'your_user_id'); // Exclude tickets created by yourself if needed
gr.setLimit(5); // Limit the result to 5 tickets
gr.query();
var ticketCount = 0;
while (gr.next()) {
ticketCount++;
}
if (ticketCount >= 5) {
// Trigger the notification logic here
gs.eventQueue('incident.assigned', gr, 'your_group_id');
}
- Customise the notification body that will be triggered the when above event is fired and save it
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 11:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2023 12:54 AM - edited 06-23-2023 12:55 AM
Hi @dhineshkumar ,
Hope you are doing great.
- Create a new Business Rule on to "Incident" to target the incident ticket table. In the "When to run" section, choose "After" and select the "Insert" and "Update" options. And, in advance section use above script only provided for reference.
Create a new Event and Notification:
Navigate to "Event Registry" to create a new event.
Set the "Table" field to "incident" to target the incident ticket table.
In the "Filters" section, add the following filter condition:
- Event filter: incident.group.assignment.notification
- Condition: current.assignment_group == event.parm1
Save the event.
create New to create a new Notification.
Set the "Type" to "Email" or the desired notification type.
In the "Notification" section, configure the recipient, subject, and message content of the notification.
Save the notification.
Set up a Schedule Job:
- Navigate to "Scheduled Jobs" in the ServiceNow instance.
- Click on "New" to create a new Schedule Job.
- Provide a meaningful name, like "Incident Group Assignment Notification Scheduler."
- Set the "Run" field to "Recurring".
- Configure the desired frequency, such as running every 15 minutes.
- In the "Advanced" section, add the following script:
(function run() {
var gr = new GlideRecord('incident');
gr.query();
while (gr.next()) {
gs.eventQueue("incident.assignment.notification.rule", gr);
}
})();
Regards,
Riya Verma