How do you create a requests metric for when an item is assigned to a user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 08:41 AM
We need to track when a request is assigned to a member of our team, the use case is that we want to create a metric that all items are assigned within two hours of them being created. I believe this can be done easier with incidents metric field, I am not sure how you do this with requests.
I've attempted to follow this guide on creating a metric but I think this may be beyond my skill set to script this.
I appreciate your help!
- Labels:
-
Benchmarks
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 09:11 AM
Could you please provide the table you will be using? Is it sc_request or sc_req_item or sc_task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 09:36 AM
Hello,
I created a metric for incident assignment, you can use same logic for other table also, just copy and paste the code and it should work.
I have tested it for 1 minute and it is working fine for me, that piece of code i have commented out in script.
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
if (!gs.nil(current.assigned_to)) {
createMetric(current);
}
function createMetric(current) {
var mi = new MetricInstance(definition, current);
if (mi.metricExists()) {
return;
}
var gr = mi.getNewRecord();
var time = gs.dateDiff(current.getValue("sys_created_on"), gs.nowDateTime(), true);
var timeInHours = parseInt(time / (60*60));
if (timeInHours < 2) {
gr.field_value = true;
}
// var timeInMinutes = parseInt(time / 60);
// if (timeInMinutes < 1 ){
// gr.field_value = true;
// }
else {
gr.field_value = false;
}
gr.field = null;
gr.calculation_complete = true;
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 01:56 PM
Thank you, I'll test this early next week!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2018 06:28 AM
Pulling in a member from my programming team to assist, this may take a little bit but will follow up. I appreciate your help!