Getting a report sent to only groups that are on that report

lukeu
Tera Contributor

Let me see if I can explain this so others can understand it. What I've created is a report that shows me Incidents that are for a certain location, also assigned to a Group but the "Assigned To" is blank. I would like to schedule this report to run but only send to the groups that doesn't have the "Assigned To" filled in to remind them of the ticket.

Does anyone know what scripting code I could add in the Condition area of the scheduled report to be able to pick up the Group and email them the report? I'll take other suggestions also.

Thanks!

1 ACCEPTED SOLUTION

amlanpal
Kilo Sage

Hi Luke,



If you are looking for sending the Scheduled report dynamically to the Assignment groups (to the Group Email) of the records which do not have any Assignee ('assigned_to' is empty) available in the report, then you need check the field 'Conditional' and write your code in the 'Condition'. There is a very good thread on this, you may refer HELP! How to dynamically set recipients of an existing Scheduled Report to email addresses that are ...   For your simplicity I'm providing your code below.



var scheduleReport = new GlideRecord('sysauto_report');


scheduleReport.get(current.sys_id); //Sys ID of your schedule Report



var tablename = scheduleReport.report.table;


var query = scheduleReport.report.filter;


var groups= '';



//Execute the report as a GlideRecord with the set table and condition


var gr = new GlideRecord(tablename);


gr.addEncodedQuery(query);


gr.query();


while (gr.next()) {


  if(gr.assigned_to == '') //Get those records which has Assigned to blank


      groups+= ',' + gr.assignment_group;   //It will get the assignment group of the corresponding records  


}



current.group_list = groups;


current.update();



// Need to set this true for condition script to run


answer = true;



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

1 REPLY 1

amlanpal
Kilo Sage

Hi Luke,



If you are looking for sending the Scheduled report dynamically to the Assignment groups (to the Group Email) of the records which do not have any Assignee ('assigned_to' is empty) available in the report, then you need check the field 'Conditional' and write your code in the 'Condition'. There is a very good thread on this, you may refer HELP! How to dynamically set recipients of an existing Scheduled Report to email addresses that are ...   For your simplicity I'm providing your code below.



var scheduleReport = new GlideRecord('sysauto_report');


scheduleReport.get(current.sys_id); //Sys ID of your schedule Report



var tablename = scheduleReport.report.table;


var query = scheduleReport.report.filter;


var groups= '';



//Execute the report as a GlideRecord with the set table and condition


var gr = new GlideRecord(tablename);


gr.addEncodedQuery(query);


gr.query();


while (gr.next()) {


  if(gr.assigned_to == '') //Get those records which has Assigned to blank


      groups+= ',' + gr.assignment_group;   //It will get the assignment group of the corresponding records  


}



current.group_list = groups;


current.update();



// Need to set this true for condition script to run


answer = true;



I hope this helps.Please mark correct/helpful based on impact