Scheduled reports

Vaishali 11
Tera Guru

I have 2 scheduled reports on incident & ritm table respectively and the data is sent through excel format. The user wants that the records which are there in the excel can also be seen in the email body.

Is that feasible to do? If yes, how can it be done?

 

 

Thanks in advance!!

2 ACCEPTED SOLUTIONS

System Notificaiton >> Email >> Mail script

(function runMailScript(current, template, email, email_action, event) {

         var inci=new GlideRecord('incident');
		 //inci.addQuery('')//pass relevant query here as per report
		 inci.query();
		 template.print('Inci count is '+inci.getRowCount());
		 
		 }

})(current, template, email, email_action, event);

 

Call mail script in format

${mail_script:getcountofrecords}

View solution in original post

Hello @Vaishali 11 ,

You can actually write an email script for this to fetch the count of the records .

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here

 var gr = new GlideRecord('sc_req_item');
 gr.addQuery('active',true);
 gr.query();

 template.print ("RITM Count "+ gr.getRowCount());


 var inc = new GlideRecord('incident');
 inc.addQuery('active',true);
 inc.query();

 template.print ("Incident Count "+ inc.getRowCount());

 
})(current, template, email, email_action, event);

Screenshot 2023-08-11 at 17.49.47.png

 

Also call the email script in the notification

Screenshot 2023-08-11 at 18.34.30.png

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

 

 

View solution in original post

9 REPLIES 9

Could you please provide me an overview of that how that can be done

 

Thanks

System Notificaiton >> Email >> Mail script

(function runMailScript(current, template, email, email_action, event) {

         var inci=new GlideRecord('incident');
		 //inci.addQuery('')//pass relevant query here as per report
		 inci.query();
		 template.print('Inci count is '+inci.getRowCount());
		 
		 }

})(current, template, email, email_action, event);

 

Call mail script in format

${mail_script:getcountofrecords}

Hi Jaspal,

 

In the report the condition is being written on assignment group, state and opened.

Are you referring to that for the query?

Yes, that is correct.

Hello @Vaishali 11 ,

You can actually write an email script for this to fetch the count of the records .

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here

 var gr = new GlideRecord('sc_req_item');
 gr.addQuery('active',true);
 gr.query();

 template.print ("RITM Count "+ gr.getRowCount());


 var inc = new GlideRecord('incident');
 inc.addQuery('active',true);
 inc.query();

 template.print ("Incident Count "+ inc.getRowCount());

 
})(current, template, email, email_action, event);

Screenshot 2023-08-11 at 17.49.47.png

 

Also call the email script in the notification

Screenshot 2023-08-11 at 18.34.30.png

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks