Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned

shawshipra
Tera Expert

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

 

shawshipra_0-1670881429036.png

 

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

 

5 REPLIES 5

newhand
Mega Sage

HI @shawshipra 

 

I'm not sure of this, but in the pic  there is a note above the script field  "  script need to be referenced by column name(not column lable.)",

and your scripts  returns  sys_id  not column name...

 

 

 

 

Please mark my answer as correct and helpful based on Impact.

shyamsundar1177
Kilo Contributor

Paste that script here

Hello shyamsundar,

 

PFB script:

 

function getTaskType() {

// gs.log("HR Task Type Log Checkkkk 000");
// gs.log("HR Task Type Log Check 0077" + current.mi_table);


var grTable = new GlideRecord('sys_db_object');
grTable.addQuery('name', current.mi_table);
grTable.query();
if (grTable.next()) {
return grTable.sys_id;
}

}
getTaskType();

 

Regards,

Shipra

Sagar Pagar
Tera Patron

Hi @shawshipra,

 

Try this updated scripts -

function getTaskType(){

var table_name = "incident"; // add tbale name here

var tableObj = new GlideRecord("sys_db_object");
tableObj.addQuery("name", table_name);
tableObj.query();
if(tableObj.next()){
    return tableObj.getUniqueValue();
}

}
getTaskType();

 

 

Thanks,
Sagar Pagar

The world works with ServiceNow