How to build scripted breakdown mapping for field that holds a string of sys id's with comma separated

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2019 12:11 PM
Hi All,
I'm having an indicator on the metric_instance table. this metric holds in the 'field value' field two sys_id's separated by comma (string field).
And I have an indicator that has two breakdowns one is on the users the other is on the groups.
Each one of the breakdowns has his own scripted breakdown mapping.
When I executing a job on this indicator I'm having this error :
'
Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned: Undefined in script: var getEngineerSysId = function(){
var str = current.field_value.getDisplayValue();
var arr = str.split(",");
return arr[1].toString();
};
at com.snc.pa.dc.Script.handleException(Script.java:215)
at com.snc.pa.dc.Script.evaluate(Script.java:176)
at com.snc.pa.dc.Script.evaluate(Script.java:156)
at com.snc.pa.dc.DataCollector.collect(DataCollector.java:385)
at com.snc.pa.dc.DataCollector.collect(DataCollector.java:313)
at com.snc.pa.dc.DataCollector.collect(DataCollector.java:247)
'
what am i doing wrong ?
Thanks
The metric table:
Breakdown mapping script:
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 02:23 PM
Have you looked at using SLA Breakdowns? If you have an SLA for resolution, you may get all of this info (and more) for very little effort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2019 01:53 PM
If you have a list field, you don't need to do anything. Performance Analytics handles breaking down a list of sys_ids natively (there is a little work to do if you are breaking down by a list of choices).
Just set this field as the mapped field and you should be all set.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2019 02:10 PM
Hi Adam,
the 'field_value' field is a string value and in my case its holding two sys_ids one is for the groups breakdown and the other is for the user breakdown, thats why I cant set this field as a mapped field i need to build a script that extract the match sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 01:58 PM
Why does this field exist? Why not have one field for the group one for the user? There is a lot going wrong here and Performance Analytics is the least of your issues.
You should still be able to breakdown by this list, one value would go to "unmatched" and one would be put with the correct element.
If you aren't using reference fields correctly and treating a ServiceNow table like an ordinary database table, you are leaving a lot of value on the table in terms of what you can get from your ServiceNow investment.
Here is a short example of why you need to fix this in your data model instead of using a script: https://community.servicenow.com/community?id=community_blog&sys_id=2f99990fdbee5b00fece0b55ca9619fb
You can't report your way out of a bad data model so I suggest you fix that first, then the Performance Analytic configuration should be very simple (and performant).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2019 02:01 PM
Can you do this as two metrics instead of one? Perhaps as just a normal duration metric instead of a scripted one?