- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2016 06:24 AM
Hi All,
I'm trying to capture the first time an incident is assigned to each assignment group.
For example:
Assignment Group Metric
Service Desk Capture
Incident Management Capture
Networks Capture
Incident Management Don't capture
Databases Capture
Networks. Don't capture
I know that metrics will capture each assignment, but I just need the first. I assume I need some sort of scripted metric?
Thanks!
Mithun
Solved! Go to Solution.
- Labels:
-
Performance Analytics
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2016 10:45 PM
Mithun,
Out of the box, there is a Metric Definition "Assignment Group" that does almost what you want, but does a bit more than what you want. The out of the box Metric would create a new Metric Instance record each time the assignment group changes, and calculates the duration for which the task record stayed with that assignment group. So if the task record were to be assigned back to the same assignment group again, you will see two Metric Instance records. But nevertheless, you will still be able to sort the records to figure out the first time the task was assigned to that group.
The Metric Instance records would look like below, when the Task assignment changes in the sequence of: CAB Approval, Database, Network, Database, Hardware.
If you want you can always create a script based Metric Definition, that does exactly what you are looking for. The script would look like:
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
// Initialize the MetricInstance
var mi = new MetricInstance(definition, current);
// Check if a metric already exists for the current task for assignment group
if (!metricExists()) {
var gr = mi.getNewRecord();
gr.field_value = current.getValue(definition.field);
gr.start = current.sys_updated_on;
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}
function metricExists() {
var gr = new GlideRecord('metric_instance');
gr.addQuery("id", current.sys_id);
gr.addQuery("definition", definition.sys_id);
gr.addQuery("field_value", current.getValue(definition.field));
gr.query();
return gr.hasNext();
}
I am attaching the XML file for the sample Metric Definition, that you can import into your instance and test easily.
The Metric Instance records would look like below, when the Task assignment changes in the sequence of: CAB Approval, Database, Network, Database, Hardware.
You can see that in this case, there is only one record or Database group, even though task was assigned to Database, multiple times.
Hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2021 04:38 AM
Hye did u get the solution for this, i am looking for a similar solution for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 06:47 AM
hi
any suggestion would help here.
Regards,
Kalpana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 05:37 PM
Thanks,
Pullaiah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 09:40 AM
The above script works perfectly. If you are trying to capture the first assignment group, please remove the line :
gr.addQuery("field_value", current.getValue(definition.field));
This line checks where a metric instance already exists for the same assignment group under the current definition. If it does, no new instance is created. By removing it, the script only checks whether any metric instance exists for the record and the definition, which is true during the first assignment and hence prevents multiple metric instances and captures the first assignment. Hope this helps!