Dynamic and individual Emails based on the Report out to the Assignment groups Managers

mikekirschen
Giga Contributor

We have requirements to send individual emails to the assignment groups managers for opened incidents assigned to their groups. I have scheduled the report to run every Monday and I used the following script to retrieve the Assignment Groups Managers, based on the report outcome and add them to the recipients list. This is working by emailing the report to the respective group managers dynamically. The new requirement is to send separate emails to the groups managers.

----------------

var GroupManager = ''; // to hold Group's Manager for each looped row

// get pre-existing User recipients from definition above and append separator (works with or without existing Users)
var UserList = current.user_list + ',';
var scheduleReport = new GlideRecord('sysauto_report'); // get details directly from this Scheduled Report
scheduleReport.get(current.sys_id);
var tablename = scheduleReport.report.table; // gets the table that the above Report points at
var query = scheduleReport.report.filter; // gets all the Report's predefined clauses and other criteria
var gr = new GlideRecord(tablename); // set up a LOCAL GlideRecord object using the Report's table
gr.addEncodedQuery(query); // apply to it all the Report definitions found above
gr.query(); // execute the Report query into the LOCAL GlideRecord object
// ----------------------------

while (gr.next()) { // loop through each LOCAL record until done
// get the applicable recipients (field names are Report-specific!) and append each to the existing list
GroupManager = gr.assignment_group.manager;
UserList += (GroupManager + ',');
}
current.user_list = UserList; // override the user_list
answer=true;

------------------------------------------

Appreciate the assistance 

1 ACCEPTED SOLUTION

In that case update the active query line to

gr.addEncodedQuery("stateIN1,2,3"); // Update the state values

 

View solution in original post

11 REPLIES 11

Hi Mike

 

I have created the report and scheduled it.

Created scheduled job as mentioned above and able to get the logs.

Email is not getting triggered verified in the email logs.

 

Please let me know is there something i am missing.

 

GlideAggregate or GlideRecord?