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

Chuck Tomasi
Tera Patron

Hi Yeny,



Try going to Studio and using the code search to find something like report.getRootReport(). Be sure to check the box to look in all scopes. That should lead you in the right direction.


Hi Chuck,



Thank you for your response! I can't find where I would do a code search in studio. I only have two options, one for searching in applications and one for creating applications. Any suggestions of where i can go from here?



Thank you,


Yenystudio.PNG


Hi Yeny,



Click View Applications (or Go on that left side). You will then be brought to the Studio Screen. There is a Code Search (in the upper right if I remember the layout of that release properly.)


Hello Yeny,



Please refer the below blog for more info.


Using Code Search to make developing on the platform easier