how to automate the daily reports(like Incidents, which Tasks,RITM's,change request)are assign to particular group.

padhu1
Kilo Expert

Hi Friends,

    how to automate the daily reports(like Incidents, which Tasks,RITM's,change request)are assign to particular group.please any one suggest sample code.

Thanks in Advance.

5 REPLIES 5

Alikutty A
Tera Sage

Hi,



You should be using a scheduled report to mail reports to required groups. Have you tried it?



Please read Scheduling and Publishing Reports - ServiceNow Wiki



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


hi alikutty ,i am looking for the sample code.


Hi Padhu,



Generally, you do not need to have code for this. All you have to schedule reports either via Scheduled Reports module or via specific report itself (please find section 3 Scheduling and Publishing Reports - ServiceNow Wiki ). You need to follow the below steps only.



1. Please navigate to Reports-->Scheduled Report. Click on 'New' button and define your own scheduled report.


2. You need to mention/select the particular report which is needed to be scheduled. You also can select when it will send (i.e., Daily or Weekly etc.). You are supposed to select the Subject, Any Introductory message and also the recipients in the Users and Groups fields respectively.


find_real_file.png


3. There is also an option available of scheduling multiple reports at a time. Please refer section 4 Scheduling and Publishing Reports - ServiceNow Wiki .



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


Hi Padhu,



If you are looking for sending the Scheduled report dynamically to the Assignment groups (to the Group Email) of the records 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()) {  


  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