- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 05:46 AM
Purpose:
We have a team that wants to measure how many times they are touching an Incident and who did the touch, they define a touch as adding a Work Note from their team. Because they do NOT assign Incidents to individuals we cannot use assignment metrics.
Problem:
I have created a metric with the purpose of having the Work Note trigger the creating of the metric. My desire is to have the metric records contain the field_value = [Name of User] and value=[sys_id of User]. The metric is created as I expected it to, however no matter what I try to put in the value field of the metric_instance record, I always get the contents of the work note and not the sys_id. The field_value is correctly populating the user name. How can I populate the metric's value field with what I need?
Script details
TABLE:Incident
FIELD:Work notes
TYPE: Script calculation
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
createMetric();
function createMetric() {
// Only process if TMSS group is assigned to Incident
if (current.assignment_group.getDisplayValue()!='IT Service Desk TMSS' ) //using Name for Dev only
return;
var mi = new MetricInstance(definition, current);
var gr = mi.getNewRecord();
var uname = current.sys_updated_by;
var ugr = new GlideRecord('sys_user');
ugr.get('user_name', uname);
gr.field_value = ugr.name;
gr.field = definition.field;
// nothing is working here //gr.value = 'A PUPPY!';// ugr.get('sys_id'); //ugr.sys_id
gr.start = current.sys_updated_on;
gr.end = current.sys_updated_on;
gr.calculation_complete = true;
gr.insert();
}
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 07:46 AM
Hi Ryan,
You will be able to update 'value' field if you don't update 'field_value'. There is a OOB Business rule on Metric Instance which will override 'value' field before insert, if you change 'field_value'.
Try commenting the below line:
gr.field_value = ugr.name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 07:46 AM
Hi Ryan,
You will be able to update 'value' field if you don't update 'field_value'. There is a OOB Business rule on Metric Instance which will override 'value' field before insert, if you change 'field_value'.
Try commenting the below line:
gr.field_value = ugr.name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 09:16 AM
Thanks for the reply Nagarani. I did comment out the 'field_name' assignment and used the sys_id of the user record which worked fine. I guess if I want additional user attributes I now have the sys_id to take me there.
Thanks for the knowledge!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2020 06:00 AM
I have asked a similar question , Would you be to create a script ??