Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 01:46 PM
Hello All,
Trying to create breakdown mapping on HR case - Metric Instance database view to get breakdown on task type
Below is the snapshot of script
but on running the data collector job i am getting error stating - " Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned: Undefined in script:"
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 07:41 AM
Hi @shawshipra
A breakdown script always needs to return something. We had the same issue where the solution was to create a variable that returned the sysid if we found something and an empty string if we didn't.
The error is actually saying that your return is undefined in those cases where no record was found.
So for your script this would look something like this:
function getTaskType() {
var sysIdToReturn = "";
var grTable = new GlideRecord('sys_db_object');
grTable.addQuery('name', current.mi_table);
grTable.query();
if (grTable.next()) {
sysIdToReturn = grTable.sys_id;
}
return sysIdToReturn;
}
getTaskType();