Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments"

andrebal
Kilo Contributor

In Performance Analytics we are trying to create a breakdown, based on the Age of CI, referenced in the cert_audit_result table

It should be based on the sys_created_on and the time the script actually runs picking up the system date/time.

Our input is the cert_audit_results table, and then the referenced CI on a record where we want to use it's sys_created_on field for the calculation of the CI age.

We get below error in our collector job log:

Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script: var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};

var enddate= gs.nowDateTime();

var days=function(x,y){return diff(x,y)/(24*60*60*1000);};

days(current.cmdb_ci.sys_created_on, enddate);

Below the script and its settings.

I read the fields selection should match the field in the script, and I this it does.

Any suggestions what I am doing wrong ?

find_real_file.png

1 ACCEPTED SOLUTION

I have tried the below myself in an instance, and it does not produce errors.



var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};


var hours=function(x,y){return diff(x,y)/(60*60*1000);};


hours(current.configuration_item.sys_created_on, score_end);



Do you see something similar as below in the collection log:



Fullscreen_28_06_16_10_22.jpg



Especially the line with "Fetching "sys_id,configuration_item.sys_created_on" from "cert_audit_result"" is interesting because here it passes configuration_item.sys_created_on as current.



One of the things I am wondering about is if the user that is used in the 'run as' in the collection job has the correct ACLs to fetch 'cert_audit_result.configuration_item'. It seems unlikely, and I am not sure what kind of error that would produce in the collection log, but I have seen stranger things.



Best regards,


Erik


View solution in original post

16 REPLIES 16

andrebal
Kilo Contributor

Also tried the almost original script from incident.age.days:



Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script: var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};


var days=function(x,y){return diff(x,y)/(24*60*60*1000);};


days(current.cmdb_ci.sys_created_on, score_end);



Gives the same error!


Hi Andre,



looking at 'cert_audit_result' table that is passed at source, I think it should be 'current.configuration_item.sys_created_on'.



The field referencing CI in 'cert_audit_result' is named 'configuration_item'.



Best regards,


Erik


Erik,



Thanks for the tip, but already tried this and still the same result!.


Andre


hmm, based on the OOB Audit Result table and columns, I would also think that the reference should be configuration_item.sys_created_on and not cmdb_ci.sys_created_on.


Scripts _ ServiceNow 2016-06-27 14-32-11.png



Did you change the OOB table?