- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2017 08:53 PM
Hi All,
I've read several similar questions and been through the answers. Needless to say I'm left needing to ask my own question.
I want to use the OOTB Reporting module (version=helsinki) to report on all tickets assigned to a group (I'll actually use a Parent group, and pivot the results by each child group), which have specifically been 'touched' or 'handled' by another particular team. Let's call that team "Team Z"
I can confirm that Team Z will actually add a Work Note such as "Assigned to Team A" to every ticket they 'touch' or 'handle'. So not only will they have an entry in the History table, it also appears in Notes. This may assist in your ideas/responses.
So lets say last month there were a total of 200 tickets assigned to, and closed by Team A.
I want to be able to tell how many of them had passed through the Team Z queue prior.
I know there is a reassignment count also, but not sure it's going to help me out in this case. I'm presently fiddling using the 'keyword' function but I've read the Notes table is not indexed so I could potentially create a vortex if I continue. And of course, I've noticed I can't 'layer' keyword criteria in a single query, or use the AND function. (I take it this is a known limitation?)
Any help is appreciated. I should repeat that I need to run this in the gui itself. That said, if the only way the above can be achieved is by direct query then don't hold back!
And if you need me to clarify anything, or add information please let me know.
Thanks in advance,
Scott
Solved! Go to Solution.
- Labels:
-
Performance Analytics
-
Reporting
- 86,995 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 07:54 PM
Hey Scott, this should get you what you're looking for.
Create a metric called something like Incident Touched. Use the following settings:
- Name: Incident Touched
- Table: Incident [incident]
- Field: Assignment group
- Type: Script calculation
- Timeline: (leave blank)
- Active: True (checked)
- Description: Creates a metric to record that an assignment group touched an incident. Does not create duplicate metrics if an incident is assigned to an assignment group multiple times.
- Script: See below
Script:
/**
* Creates a metric to record that an assignment group touched an incident.
* Does not create duplicate metrics if an incident is assigned to an
* assignment group multiple times.
*
* Parameters
* These parameters are passed into all metric definition scripts.
*
* current
* The current record that triggered the metric definition
*
* definition
* The metric definition being triggered
*
* mi
* A MetricInstance object (see the MetricInstance script include for more
* information and documentation). I'm not a big fan of using the mi object
* because it doesn't really contain complete functionality or the ability
* to customize metrics to the extent that a custom script normally
* demands.
*
* Created by Dennis R
* 2017-08-16: Initial creation
*/
(function calculateMetric(current, definition, mi) {
// Check to see if a metric instance already exists for this ticket
// assigned to this assignment group
var grMetric = new GlideRecord('metric_instance');
grMetric.addQuery('id', current.getValue('sys_id'));
grMetric.addQuery('definition', definition.getValue('sys_id'));
grMetric.addQuery('value', current.getDisplayValue('assignment_group'));
grMetric.query();
if (grMetric.hasNext()) {
// If so, then this ticket has already been counted for this assignment
// group and there's no need to do anything.
}
else {
// If not, create one
var now = new GlideDateTime();
var instant = new GlideDuration(0);
grMetric = new GlideRecord('metric_instance');
grMetric.initialize();
grMetric.setValue('table', current.getRecordClassName());
grMetric.setValue('id', current.getValue('sys_id'));
grMetric.setValue('definition', definition.getValue('sys_id'));
grMetric.setValue('field', definition.getValue('field'));
grMetric.setValue('value', current.getDisplayValue('assignment_group'));
grMetric.setValue('duration', instant);
grMetric.setValue('business_duration', instant);
grMetric.setValue('calculation_complete', true);
grMetric.setValue('start', now);
grMetric.setValue('end', now);
grMetric.insert();
}
})(current, definition, mi);
(You won't hurt my feelings too much if you leave it unattributed to me; that's just a standard header I put on all my scripts.)
Save the metric definition. This is a screenshot of what your settings should look like on the definition:
Now create the report. Run it against the Incident Metric [incident_metric] database view. Make sure you add the following filter conditions:
- Definition is Incident Touched
- Value is Team Z (note that because Value is a text field, you'll have to type this in instead of selecting it)
If you don't want tickets that ultimately ended up in Team Z's queue (for example, only tickets that ended up in the queue of Team A, Team B, or etc.), then add a filter for:
- Assignment group is not Team Z
If you want tickets that ONLY ended up in a queue of Team A, Team B, or etc. (that is, that didn't end up in some outside queue), add a filter such as:
- Assignment group is Team A OR
- Assignment Group is Team B OR
- Assignment Group is Team C OR
- ...
Personally, I would save this filter as a report source so that if you decide you want to filter it further by other criteria, you don't have to keep adding those filters first. After that, you can add whatever other filters you want, such as created between, updated after, or whatever.
When that report is run, you will get a list of tickets without duplicates that were touched by Team Z at some point and, if you added the assignment group is not Team Z filter, ended up in some other team's queue.
If you just want a count and not a list of tickets, change your report time from List to Single Score. (But I'd leave it as list at least initially to validate that you're getting back the records you're looking for.) And as a side note, the time that the ticket was initially assigned to Team Z will be in the Start field of the Incident Metric view.
Hope this helps, and let me know if you have any trouble,
--Dennis R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 04:53 PM
Hi Dennis,
You are absolutely right, I want to report using the "Assigned To" function. Please disregard my mention of the "Work Notes", as it's not relevant to the report I am attempting to construct.
(I realise this will also pick up tickets that were assigned to Team Z accidentally, in which case there has been no 'touch' as you rightly point out - but we can work with that)
I look forward to your ideas, and appreciate your help so far.
Sachin I'm not going to be able to have custom fields added to existing forms unfortunately. Due to this essentially being a change impacting the entire environment, it would have to be developed as such. (not going to happen for one team's reporting desires)
Regards,
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 08:39 PM
This will take me a while to figure out, I'll have to create a metric definition script to do what you're asking. It will probably be tomorrow night before I can circle back and take a crack at it.
Before I do though, I have to ask given what you posted above, do you have access and authority to create a new metric definition using a script calculation? If you don't, then I think what you're asking for will be all for naught. You might have considerably more leeway to create a metric definition than a new field on a table since it won't affect the rest of the environment.
My general strategy would be to create a custom script calculation on a metric that, when the assignment group field changes, looks to see if a metric instance for the new assignment group for that incident already exists. If not, then it will create one. If so, then it will ignore it.
That should result in getting incident metrics that show each incident a group touched one and only one time.
--Dennis R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2019 04:08 AM
Hi Dennis
did you mange to created a script for assigned to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2017 09:02 PM
Hi Dennis,
Sachin had suggested something similar previously and I found I didn't have the required access to Metrics, but have requested it so I hope to be able to create definitions very soon. (this is by far more preferable than creating a change to the whole environment)
I was hoping to be able to apply it across the existing data though, rather than having it function from when the metric is first defined. Is there not a way to use existing tables and the reporting module as opposed to scripting it? (I'm guessing not, else I'm sure it'd be a sticky thread on here - I've seen other ask similar questions before)
Regards,
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 10:40 AM
There really isn't, other than exporting the contents of the metrics table to something like Excel and massaging the data there. You'll need the help of your friendly neighborhood ServiceNow admin, or access to create metrics definitions.
For what it's worth, metrics definitions are extremely flexible and very cool.