is there a way to create a report to show the time since last P1 creation

shireddy
Kilo Explorer

is there a way to create a report to show the time since last P1 creation

2 REPLIES 2

Nitesh Balusu
Giga Guru

You can always create an indicatos, with conditions where you will subtract the current date and the date the P1 was opened/resolved.

Josh Cooper
ServiceNow Employee
ServiceNow Employee

There are a couple of things you can do... each with their own limitations, though.

 

1.  Like Nitesh pointed out, you can do an indicator in Performance Analytics.  It's going to weird though because you're not going to be able to specify exactly when the last p1 was.  (It'd be cool if you could do a 'Top 1' in the Indicator to show only the most recent one.  Honestly the best way to do it here, and the cleanest overall, would be to make a single row indicator source, just any indicator source that returns one row, doesn't matter what because you'll override it in the PA Indicator Script.) 

Note, this is an advanced trick, definitely test it out thoroughly before trying it in Prod!

But you'd set up an indicator that returns one row, like looking at the core_country table, with a filter for Name = United States... or whatever.  As long as it returns one row.  I used to use "Incident Number = " and pick an early incident number, but if you ever start using system archiving, it'll break and be hard to tell what happened. 😛

Once you've got your one row indicator source, add a new Automated Indicator.  Change type to "SUM" and then use the Script box to create a new script.  Take a look at one of the existing scores for Age, how it compares the number from the record it's looking at to 'score_end' to get the current time?  You're just going to need to do a lookup to the Incident table, for P1s created within the last 30 or 90 days, with an orderByDesc on sys_created_on (or opened, whichever you prefer),  then use THAT date instead of current. whatever (because in this case your current record is whatever your indicator source has... like US from the Country table.)  Make sure the actual code for the script is wrapped in a formula, call the formula, and within the formula, have it return the answer you got from dateDiff (or however the Age does its thing.)

Add it to a job and let it run, and it should populate the automated indicator with the time since last P1, inside the script you can modify it to show in hours or days by multiplying your result... the default depends on which formula you copy.

Note:  This will only report time since last P1 at the time the job runs.  It won't update throughout the day.  If your job runs at 1am, then the time since last P1, done this way, will be the same at 8am and 2pm and 9pm that next day.  AVOID the temptation to set a job to run every 5 minutes!  That will definitely impact the system, but you likely won't notice in Dev or Test... you most likely WILL notice in Prod, because the PA Jobs, I believe, also share worker nodes with Integrations and other things, depending on how those things are set up.

 

2.  You can do something similar in Metrics - the idea would be to create a new Metric Definition, pointed at the Incident table, that runs whenever a P1 is opened.  Again, take a look at the other scripted Metrics to see how they work, but the idea is similar - whenever a new P1 is opened, have it pull a glideRecord list of the most recent P1s, limited by 30 or 90 days (to prevent scanning millions of records, eventually) and use that dateDiff function like we use in the Age scripts to calculate the difference from this P1 opening to last.

The plus side of this, is you can do it even if you don't have PA -

The downsides are, it's more complicated, and will only run in terms of P1 creation.  Like if you're having a happy time of little issue, you won't be able to see how long it's been since the last P1... when the NEXT P1 opens, it'll store that value for you though, so you can see the most recent record.  Not great in times of peace, but if you're just looking to understand something like Mean Time Between Failures, it'll do fine.

 

3.  Honestly this is the best and coolest way, but the way I can help the least with.  Look around though, someone may have done it.  For a dashboard, PA or otherwise, you have access to dynamic content blocks from Service Portal.  You can write a new widget in a dynamic content block, that does the same as we would in the PA script, and collects the most recent P1 created time, and does the calculation either onLoad, or more ideally, provides almost a counter type thing that will constantly update as you look at the dashboard.  You'd probably want to set it up to do a callback every few minutes to see if there's been a new incident created, or tie that into the push notifications somehow, otherwise it'll only be in terms of when the dashboard was loaded, and won't know if a new P1 has been created since.

There's a lab out there by Adam Stout from the last Knowledge Expo I think, that covers how to create dynamic content blocks and even how to have them listen to interactive filters, I believe.  I'll admit that client side is not my specialty, I can usually muddle through but it takes a lot of time.

The upside to this one:  It can be as visually cool as you want to make it, and even dynamically count right there in the browser while you watch.  It will tell you definitely the exact time since the last P1, not the time from the last score collection, and without having to wait for a NEW P1.  (Try explaining to the incident time that you created a P1 just to see how long it's been.  They generally do NOT approve!)

The downside is, it's not a score you can keep and use.  You're not going to be able to trend it like you could with PA and see whether it's getting better or worse over time, split by department, etc, so the answer might be more than one of these.

 

4.  There might be a better way to do this that I can't think of right now.  ServiceNow is a wide open app, full of great collaboration, and it's really only limited by your imagination.  If someone's done it before, maybe they shared it?  If you end up being the first, maybe you'll share it with others.

 

Hopefully one of these will help you!