How to write a script to show tickets created with a 5min delay or more from impaired time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 07:35 AM
Hello,
I'm trying to create a report or a widget (whichever will help me illustrate best) tickets which are created with more than 5 mins delay from the actual impaired time.
I'm assuming the best way to achieve this will be in PA with a script, and have never written a script yet.
Is anyone able to please help me?
Thanks!
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 07:40 AM
Hi,
How do you determine if a ticket was created with a delay? Do you have another table in ServiceNow that indicates the actual start time of the issue ?
Thanks,
Arav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 07:52 AM
Hi There,
We have 'service impaired time,' and 'created' and 'opened.' 'created' and 'opened' are essentially the same.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 08:12 AM
Hi
You may consider using Metrics for this purpose as both fields are on the same table.
Please check existing Metric definitions that are of type "Script calculation" (please see below URL for reference).
https://<your instance>/metric_definition_list.do?sysparm_query=type%3Dcalculation&sysparm_view=
The "Create to Resolve Duration" metric definition demonstrates how two date fields are used to compute the duration. Once setup, the answers will be stored in "metric_instance" table but you can report them from Incident metrics (a database view on incident, metric definition, and metric instance).
P.S - There is a difference between "created" and "opened" times. If you open an incident form at 10 AM but actually create it after filling in relevant information at 10:20, then opened will show 10 and created 10:20.
Thanks,
Arav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 08:22 AM
Hi Arav,
Thank you for clarifying the opened vs create field purposes!
I'm not looking for duration, I'm only looking to present INC tickets which have a delayed create time of 5 minutes from 'impaired time.' We are trying to find any anomalies in our ticketing system.
Will the above URL assist with that?
Thanks!