How to create a custom report in ServiceNow ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-20-2020 06:51 AM
Hi All,
Could anyone please help to create a report in below format ? We are on Madrid release.
Thank you in advance.
Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-20-2020 10:39 AM
Hello Ashish,
we can create this kind of report using "Email Script". we have to write script for creating format like this.
after creating this script we will call this script in our "Scheduled Email Reports".
Scheduled Email Reports is used for sending reports to the user or group so we can scheduled our report directly by calling email script here.
I am just adding one example script, so you can customize this script accordingly :
(function runMailScript(/ GlideRecord / current, / TemplatePrinter / template, / Optional EmailOutbound / email, / Optional GlideRecord / email_action, / Optional GlideRecord / event)
{
var mt_count=0;
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_updated_onONThis week@javascript:gs.beginningofthisweek()()^state=3'); gr.query();
while(gr.next())
{
var cat = gr.getValue('category');
switch(cat)
{
case 'security' : mt_count++;
break;
case 'default' : break;
}
}
template.print('<table border="border: 1px solid #dddddd;" cellspacing="0" style="font-family: Time New Roman;" width="100%" height="100">');
template.print('<tr>');
template.print('<th>Incident States</th>');
template.print('<th>Open</th>');
template.print('<th>Work in progress</th>');
template.print('<th>Resolved</th>');
template.print('<th>Closed</th>');
template.print('<th>Total</th>');
template.print('</tr>');
template.print('<tr>');
//Malicious Traffic
template.print('<td>Malicious Traffic</td>');
template.print('<td>'+mt_count+'</td>');
template.print('</tr>');
template.print('<tr>');
template.print('<td>Malware/Malicious Code Activity</td>');
template.print('<td>'+malware+'</td>');
template.print('</tr>');
template.print('<tr>');
//Confidential personal identity data exposure
template.print('<td>Confidential personal identity data exposure</td>');
template.print('<td>'+confi_perso_ide+'</td>');
template.print('</tr>');
template.print('<tr>');
template.print('<tr>');
//Total
template.print('<td>Total</td>');
template.print('<td>' + (mt_count ) + '</td>');
template.print('</tr>');
template.print('<table>');
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2020 11:57 AM
Dear Sanjay,
Thanks much for sharing the email script way to achieve the same report.
In scripted report is there a possibility that we can get clickable numbers so that we can see records as well using report ? Similar to pivot type of report in ServiceNow.
Thank you in advance.
Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-31-2020 12:25 PM
Hi Ashish,
To make the number as clickable you can go through the following
Or you can try like below
var url = '<a href="' + gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">current.number</a>';
template.print(url);
Please mark it as helpful or correct based on the impact
Abdul Azeez
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-31-2020 12:35 PM
Dear ABdul,
Thanks for sharing, will try to use your uggestion.
I will see how can I make number 10 (for example) in Created column to show 10 records in list view on click.
-Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-01-2020 01:01 AM
Hi Ashish,
Yes, we can get clickable numbers in scripted report.
for (var i = 0; i <= 10; i++) {
template.print('<tr>');
template.print('<td>Malicious Traffic</td>');
template.print('<td>' + mt_count + '</td>');
template.print('<td> <a href="https://dev73300.service-now.com/incident_list.do?sysparm_query=number='+arr[i]+'">' + arr[i] + '</a> </td>');
template.print('</tr>');
}
Highlighted line print your incident number and its clickable you can see sample output below: