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

Pieter,



Already tried this.


Added some GS.log lines in the script, but they don't log anything. It seems the script is not even executed due to the error.


Andre


Check your parenthesis and semi colons on line 1 and 3.



No looks good, I should not try this on an iPhone.



Can you send a screenshot of the list view of the script that shows the column name?



Does the OOB script for incident.age.days work?


I cannot figure out is that is actually used in the oob jobs, so I dont know if that actually works.


Just checked, and that works, or at least does not give any errors.