Reminder email notifications to assignment groups of incident table

Sravani Reddy
Tera Contributor

Hello All,

 

I have a requirement that I need to send reminder email notifications for the tickets not updated more than 2 days to all assignment groups of incident table based on the condition(if assigned to is empty, it should go to assignment group members, else  assigned to is not empty, it should go to assigned to and assigned to manager)

Can anyone help me how to fetch incident list of particular assignment group?

And also I need to display in tabular format like the below. Can anyone help me with html code for this?

NumberShort DescriptionPriorityState
    
    
    
    
    
5 REPLIES 5

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Sravani Reddy ,

If it is only for one incident individually then it might be straight forward to create the notification based on condition.

But if you want all the list in tabular formate then you will have to create one report for those incidents and then scheduled that report using Scheduled Email report.

GunjanKiratkar_0-1668069097926.png

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Sebas Di Loreto
Kilo Sage
Kilo Sage

I like @Gunjan Kiratkar idea for your use case: scheduled reports at the beginning of the day.

I think the condition only applies in reference to sending the schedule report: the last line must evaluate to true to trigger the report email. The problem comes on figuring out the audience since you cannot choose different groups unless you create many different reports for each group. That would be a not scalable solution.

Another alternative would be a scheduled job where you glideAggregate the incidents not updated in the last two days by assignment group. Then you create an event with assignment group on parm1 and the list of incidents on parm2.

Then you have a notification that is triggered by that event, uses the parm1 as the recipient and you use the parm2 on the content of the email. If you want more fields about those incidents then you need an email script on the content of that message using the parm2 information.

 

Study the OOB notification case called "Group affected": /sysevent_email_action.do?sys_id=c8378399c0a80a16007243ab16d423d8

It is advanced but you will be on the right path.


If I helped you with your case, please click the Thumb Icon and mark as Correct.


Sravani Reddy
Tera Contributor

Thanks for your reply!!

 

I'm able to get the list of incidents for only one particular assignment group by using encoded query as shown below. Can you please help me with the script as how to fetch list of incidents from all assignment groups? Also I need to satisfy this condition(if assigned to is empty, it should go to assignment group members, else  assigned to is not empty, it should go to assigned to and assigned to manager)

SravaniReddy_0-1668228808779.png

 

 

I think this script can help with the "assignedTo_is_empty" case.

GlideAggregate first groups by assignment_group (parm1) and uses that information on the GlideRecord to get the list of incident.sys_ids for parm2. Remember you have to create that event name (event registry) and the notification must trigger using that event and recipient is parm1.

This event should only send a single email to the assignment_group with the list of all the incidents, if you add an email script on the body of the message using the parm2 information (sys_ids of all associated incidents).

If you want to simplify this use case you can put the incident numbers in line 14 and won't need to use the email script BUT you said you wanted the body of the message to have the number/short description/etc.

 

Then you should built another scheduled job for the other case with AssignedTo_is_NOT_empty. You use the same code, changing the mainQuery and grouping by assigned_to.

 

I left the gs.log on the code so you can see what happens if you run it in a background script.

 

SebastianDL_1-1668373538618.png

 

 

mainQuery = 'active=true^assignment_groupISNOTEMPTY^assigned_toISEMPTY^sys_updated_onRELATIVELT@dayofweek@ago@2';

var agg = new GlideAggregate('incident');
agg.addEncodedQuery(mainQuery);
agg.groupBy("assignment_group");
agg.query(); 
while (agg.next()) {
  var query = agg.getQuery();  
  var agg2 = new GlideRecord('incident');   
  agg2.addEncodedQuery(mainQuery+'^'+query);
  agg2.query();
  var incidentList =[];
  while (agg2.next()) {
     incidentList.push(agg2.sys_id.toString());
  }
  gs.eventQueue('Assignedto_is_empty',agg, agg.assignment_group, incidentList.join(','));
  gs.log(agg.assignment_group.name + ':  '  + incidentList.join(','));
}

 


If I helped you with your case, please click the Thumb Icon and mark as Correct.