Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

how to add number of CIs count in email through scheduled reports

konijetisumanth
Giga Guru

Hi community 

 

I have requirement to create a report for computer class it has count to (x) Cis, so i need to create scheduled report on monthly, so I need to show the count of (x) in my email body, please help me how can i add the reports count dynamically into my scheduled report mail.

 

example:- if my computer class has 100 cis counts in my report then the email has to say as below.

COMPUTER REPORT CI's count - 100

if the count changes by month, then it should replicate the same in my email count.

1 REPLY 1

Sonam Tiwari
Tera Guru

Hi @konijetisumanth ,

 

To do this you will have to have a scheduled job with something like below script:

updatedCount();

function updatedCount() {
    var schReport = new GlideRecord('sysauto_report');
    schReport.get("170c92d247e0f1101c8053ebd36d4384"); // your scheduled report's sys id here

    var list = new GlideRecord("cmdb_ci_computer");
    list.addEncodedQuery("os=Windows XP Professional");// whatever filter you are using in your report so as to get the correct count
    list.query();
    var count = list.getRowCount();


    schReport.report_body = "COMPUTER REPORT CI's count -" + count;

    schReport.update();

    SncTriggerSynchronizer.executeNow(schReport); //execute schedule report

}

 https://www.servicenow.com/community/platform-analytics-articles/scheduling-a-report-for-dynamic-rec...

This helped me to help you.

Thanks,
Sonam