- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 01:51 PM
One of the previous admin/developer made a change to the sys_user.name Dictionary Record a while ago, and since then our System Log has been swamped with 7,000+ "java.lang.NullPointerException" errors by the end of every day. Here is the addition to the OOTB record:
if (gs.getSession().isInteractive()) { // only do for interactive sessions
if (gs.action.getGlideURI() != "") {
if (gs.action.getGlideURI().getMap() != '') {
if (gs.action.getGlideURI().toString().startsWith('api/now/form/mention/record/')) { // @ mention is being used
// current.user_name; // return user_id field - change this combo to be anything you would like
if(current.first_name.nil()) {
current.last_name + " (" + current.email + ")";
} else {
current.first_name + ' ' + current.last_name + " (" + current.email + ")";
}
}
}
}
}
if (gs.getSession().isInteractive()) { // only do for interactive sessions
if (gs.action.getGlideURI() != "") {
if (gs.action.getGlideURI().getMap() != '') {
var uri = gs.action.getGlideURI().toString();
if (uri.startsWith('api/now/form/mention/record/')) { // @ mention is being used
//current.user_name; // return user_id field - change this combo to be anything you would like
if(current.first_name == null) {
current.last_name + " (" + current.email + ")";
} else {
current.first_name + ' ' + current.last_name + " (" + current.email + ")";
}
}
}
}
}
Any help would be greatly appreciated!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 02:08 PM
Can you put it in a try catch function and see how it goes? Also made few changes to the script
try{
if (gs.getSession().isInteractive()) { // only do for interactive sessions
if (gs.action.getGlideURI() != "") {
if (gs.action.getGlideURI().getMap() != '') {
var uri = gs.action.getGlideURI().toString();
if (uri.indexOf('api/now/form/mention/record/')>-1) { // @ mention is being used
//current.user_name; // return user_id field - change this combo to be anything you would like
if(current.first_name == null || current.first_name == "") {
current.last_name + " (" + current.email + ")";
} else {
current.first_name + ' ' + current.last_name + " (" + current.email + ")";
}
}
}
}
}
}
catch(ex)
{
gs.error(ex);
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 02:08 PM
Can you put it in a try catch function and see how it goes? Also made few changes to the script
try{
if (gs.getSession().isInteractive()) { // only do for interactive sessions
if (gs.action.getGlideURI() != "") {
if (gs.action.getGlideURI().getMap() != '') {
var uri = gs.action.getGlideURI().toString();
if (uri.indexOf('api/now/form/mention/record/')>-1) { // @ mention is being used
//current.user_name; // return user_id field - change this combo to be anything you would like
if(current.first_name == null || current.first_name == "") {
current.last_name + " (" + current.email + ")";
} else {
current.first_name + ' ' + current.last_name + " (" + current.email + ")";
}
}
}
}
}
}
catch(ex)
{
gs.error(ex);
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 07:24 AM
Thanks Sanjiv! I've applied the script above and have yet to see the error - happy holidays!