- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 09:02 AM
I have a client who is requesting a report/list of incidents whose priority has changed. I'm able to come up with a metric definition that looks at the priority field and it works fine (I'm using the type Field Value Duration). The problem that I'm having is the client wants to skip the initial priority and just list if the initial priority changes. For example, if the incident is opened as a priority 3, gets reassigned twice and then gets changed to a priority 2, only show the change from P3 to P2. Right now the way the metric definition works, it captures when the ticket is opened and assigned the original P3 priority. I'm sure there is a way to do this I just have no clue how. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 11:15 AM
Sorry Keith my bad, read as you had it as a script metric :$ - hence "// Create metric instance" comment (was expecting you to copy and paste into there)
So redone for you below, complete with script code.
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
if (current.sys_mod_count > 0) {
var mi = new MetricInstance(definition, current);
var gr = mi.getNewRecord();
gr.field_value = current.priority;
gr.field = null;
gr.calculation_complete = true;
gr.insert();
}
Definition picture:
Had to do away with isNewRecord(), didn't work - used sys_mod_count instead.
Thanks
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 09:24 AM
Hi Keith
Try adding a condition to only record an instance if the current record isn't new i.e:
if (!current.isNewRecord()) {
// Create metric instance
}
That should allow you to prevent instances being record upon initial save. Let me know if that works for you. If you're still having trouble paste the definition in here and I'll take a look for you.
Thanks
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 10:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2016 11:15 AM
Sorry Keith my bad, read as you had it as a script metric :$ - hence "// Create metric instance" comment (was expecting you to copy and paste into there)
So redone for you below, complete with script code.
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
if (current.sys_mod_count > 0) {
var mi = new MetricInstance(definition, current);
var gr = mi.getNewRecord();
gr.field_value = current.priority;
gr.field = null;
gr.calculation_complete = true;
gr.insert();
}
Definition picture:
Had to do away with isNewRecord(), didn't work - used sys_mod_count instead.
Thanks
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2016 09:41 AM
Tim,
This worked perfect. It captured just what the client was looking for. I appreciate the help!!
As usual, they always want something more. Is there a way to capture who made the priority change? I know I can use the "updated by" field but the last person who updates the ticket may not necessarily be the one who changed the priority. Any thoughts?