
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 11:03 AM
I am attempting to create a breakdown that looks at certain records on the metric_instance table and breaks down on the ID.User field. Can someone provide some guidance on how I would make a script dot-walk through a document ID field?
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 12:22 PM
Don't use a script for this. You'll get much better performance if you create a view to the table you are looking for (e.g., incident, case, etc.) and then build your indicator on that. There was a lab on this at K19 which walks you though using Performance Analytics on metrics. (I believe it is this one: https://community.servicenow.com/community?id=community_article&sys_id=686623dcdb9d3b0422e0fb2439961...)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 11:22 AM
Well the ID field is just a reference to the incident. I am not sure where you want to run this script so some variables might change but for the sake of this let's pretend you're running a fix script.
You could do something like this.
var metric = new GlideRecord('metric_instance');
metric.addQuery('id', 'SYS_ID OF THE INCIDENT');
metric.query();
if(metric.next())
{
var name = metric.getValue('id.name');
}
or if that dot walk doesn't work you can go the long way around
var metric = new GlideRecord('metric_instance');
metric.addQuery('id', 'SYS_ID OF THE INCIDENT RECORD');
metric.query();
if(metric.next())
{
//Get the sys_id from the ID field
var incId = metric.getValue('id');
//Now query the incident table with that id
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', incId);
inc.query();
if(inc.next)
{
var name = inc.getValue('name');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 12:24 PM
You don't want to use a script for this in PA, but if you were using one, I think you would want to pull the table from the dot walking to the metric definitions and looking at what table the definition is on (if it was incident, you would just use the OOTB incident_metric view).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 12:22 PM
Don't use a script for this. You'll get much better performance if you create a view to the table you are looking for (e.g., incident, case, etc.) and then build your indicator on that. There was a lab on this at K19 which walks you though using Performance Analytics on metrics. (I believe it is this one: https://community.servicenow.com/community?id=community_article&sys_id=686623dcdb9d3b0422e0fb2439961...)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2020 04:28 AM
It took some time to get our developers to build the database view, but once I had access to it, it worked perfectly. Thanks