I want to set up an notification like around 5 tickets got assigned to my group in 15 min interval.

dhineshkumar
Tera Guru

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.

5 REPLIES 5

dmi95
Tera Expert

Hi @dhineshkumar 
Do you need to get email notifications whenever tickets gets assigned to your group?Was it not following OOTB notifications?

Riya Verma
Kilo Sage
Kilo Sage

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:

  1. Create a Business Rule that runs whenever an incident ticket is assigned to your group. This rule will trigger the notification logic.

  2. Define the Notification Condition: In the business rule, specify the condition that checks if the ticket is assigned to your group. 

  3. 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

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

@Riya Verma 

Can you please provide me step by step process ??

 

Thank you.

Hi @dhineshkumar ,

Hope you are doing great.

  1. 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.
  2. 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.

  3. 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);
    }
})();
​

 

 

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma