
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 07:54 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 06:23 PM
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")

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 08:14 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 01:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 02:40 PM
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.)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 02:42 PM
Hello Yeny,
Please refer the below blog for more info.
Using Code Search to make developing on the platform easier