The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Error in System Logs

YenGar
Mega Sage

Hello all,  

I'm not sure that this is the correct categorization for this question but I would like some guidance on figuring out where these errors are coming from in our instance. The error that we keep seeing in our logs in the below:

JavaScript evaluation error on:
var report = new GlideReport(current.sys_id);
var root = report.getRootReport();
root.canRead();
Root cause of JavaScriptException: java.lang.NullPointerException
: java.lang.NullPointerException:  

It happens hundreds of times throughout the day. I've done some research on it but I can't figure out where this is coming from. Could it be due to a bad report or a report schedule problem?  

Any suggestions/ideas are highly appreciated!

 

Thank you,  

Yeny

1 ACCEPTED SOLUTION

Mwatkins
ServiceNow Employee
ServiceNow Employee

The code kind of looks like a modified version of an out-of-box ACL on the sys_report table. Try the following link (substituting for yourinstance, of course).


yourinstance.service-now.com/sys_security_acl.do?sys_id=2db8a46acb12020032a09371c24c9cd9



Is that it?



The current, out-of-box script in the ACL looks like this.


var report = new GlideReport(current.sys_id);


answer = report.isValid() && report.getRootReport().canRead();



I'd guess that somewhere out there is a reference to a report that doesn't exist anymore.


The NPE either coming from: root.canRead() or report.getRootReport().


Try wrapping the last two lines in a conditional statement like this:


if(report.isValid()) {


var root = report.getRootReport();


root.isValidRecord() && root.canRead();


} else {


false;


}



Oh, one more thing! The Studio Code Search is a great tool and I definitely endorse its use. However, here is another way to do kind of global script search:


1. Type "sys_metadata.list" in the left hand navigator and press "Enter"


2. Use the "keyword" search for a snippet from the code you are looking for (e.g. "getRootReport")


View solution in original post

6 REPLIES 6

Mwatkins
ServiceNow Employee
ServiceNow Employee

The code kind of looks like a modified version of an out-of-box ACL on the sys_report table. Try the following link (substituting for yourinstance, of course).


yourinstance.service-now.com/sys_security_acl.do?sys_id=2db8a46acb12020032a09371c24c9cd9



Is that it?



The current, out-of-box script in the ACL looks like this.


var report = new GlideReport(current.sys_id);


answer = report.isValid() && report.getRootReport().canRead();



I'd guess that somewhere out there is a reference to a report that doesn't exist anymore.


The NPE either coming from: root.canRead() or report.getRootReport().


Try wrapping the last two lines in a conditional statement like this:


if(report.isValid()) {


var root = report.getRootReport();


root.isValidRecord() && root.canRead();


} else {


false;


}



Oh, one more thing! The Studio Code Search is a great tool and I definitely endorse its use. However, here is another way to do kind of global script search:


1. Type "sys_metadata.list" in the left hand navigator and press "Enter"


2. Use the "keyword" search for a snippet from the code you are looking for (e.g. "getRootReport")


Hi Matthew, I followed your suggestion and I found a report that was being referenced but it didn't exist in the user's report list that created it. Once I removed the report and monitored the logs for 2 days, no more error messages have appeared! I believe this has resolved the issue. Thank you so much for your help!



Thank you,


Yeny