Need help on 'Script Calculation' type Metric Definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2019 07:35 PM
Good Day Team,
Currently I have created a custom Metric Definition of type 'Script Calculation' on the Assignment Group field of Incident table. The definition works properly apart from a single issue.When we are creating the Metric Instance, we are unable to create the record with different Value and Field Value. My requirement is: when new Metric Instance record is getting created we need to set the Value as the Display value of Assignment group and the Field Value as the SysID of the Assignment group.
In order to achieve the same we have already tried couple of combinations (code snippets are given below). But unfortunately those didn't work. Can you please help me resolving this issue?
/*** First Try: Did not Work***/
gr.field_value = current.getDisplayValue('assignment_group'); //Fetch the Name of the Assignment Group
gr.field = null;
/**** OUTPUT: Both Value and Field Value shows the Name of the Assignment Group ***/
/*** Second Try: Did not Work***/
gr.field_value = current.getValue('assignment_group'); //Fetch the SysID of the Assignment Group
gr.field = null;
/**** OUTPUT: Both Value and Field Value shows the SysID of the Assignment Group ***/
/*** Third Try: Did not Work***/
gr.value = current.getDisplayValue('assignment_group'); //Fetch the Name of the Assignment Group
gr.field = null;
/**** OUTPUT: Value shows the Name of the Assignment Group, Field Value is Blank ***/
/*** Fourth Try: Did not Work***/
gr.field_value = current.getValue('assignment_group'); //Fetch the SysID of the Assignment Group
gr.value = current.getDisplayValue('assignment_group'); //Fetch the Name of the Assignment Group
gr.field = null;
/**** OUTPUT: Both Value and Field Value shows the SysID of the Assignment Group***/
Thanks,
Ravi
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2020 11:13 AM
I'm aware this is an older post so I don't know if you still need assistance, but I would look at the Business Rule "metrics instance - set display value" OOB script that seems to be setting the "value" field to be the same as the "field value" field.
I can't say if this is what is causing the issue since you only provided a very small snippet of your script.
When diagnosing issues such as this my first thought is to always check what Rules/Policies are active and if they pertain to my work.