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

I notice in the script you use 'enddate'. Should this be 'score_end', as this is the PA script variable?



Performance Analytics script variables



If 'enddate' refers to a column it should start with 'current.' and it should be passed as an argument in the source section of the script.



Best regards,


Erik


here the current script:


Please note that the log statements do NOT end up in the Log!



find_real_file.png


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


Erik,



Used your script, and it seems to work. Sill testing but looking strong!


Thanks very mucht. I will let you know the final result.


Andre


Erik,



Your solutions works completely now.


Many thanks for you excellent help!


Andre