- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 02:23 PM
Hi PA Community,
I am trying to build a report for "Days since last P1 Incident" for my organizaton. I've attempted to use a Function Field within Reporting however datediff operations have to have some limitiations and I can't think of a way to have Performance Analytics do it.
Anyone have any tips or experience building a similar report?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 03:51 PM
For a quick solution,I would probably just create a new dynamic content block
instanceName.service-now.com/content_block_programmatic_list.do?sysparm_query=&sysparm_view=
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var result = 0;
var inc = new GlideRecord('incident');
inc.addQuery('priority', '1');
inc.orderByDesc('opened_at');
inc.setLimit(1);
inc.query();
if(inc.next()) {
var start = new GlideDateTime(inc.opened_at);
var now = new GlideDateTime();
var diff = GlideDateTime.subtract(start, now);
var days = diff.getRoundedDayPart();
result = days;
}
</g:evaluate>
<p><span style="font-size: 36pt; color: #ff0000;"> ${result}</span></p>
</j:jelly>
Longer term solution, look into seeing what's possible through PA.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 02:34 PM
Is this for a dashboard or do you need something in the reporting module?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 02:37 PM
Hi @Mike_R ,
Thank you for your reply. I need to display this report in a dashboard for my organization.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 03:07 PM
Do you need the datediff for every Incident or do you just want for the most recent P1 Incident such as
var inc = new GlideRecord('incident');
inc.addQuery('priority', '1');
inc.orderByDesc('opened_at');
inc.setLimit(1);
inc.query();
if(inc.next()) {
var start = new GlideDateTime(inc.opened_at);
var now = new GlideDateTime();
var diff = GlideDateTime.subtract(start, now);
var days = diff.getRoundedDayPart();
gs.log('Number of days is ' + days);
}
*** Script: Number of days is 356
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 03:21 PM
Thanks @Mike_R this is helpful. I am looking for a datediff for most recent P1. How do you suggest visualizing this on a dashboard?