Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to fix com.glide.ui.ServletErrorListener source error ?

kun1
Tera Expert

Hi All,

While check the error in the system logs, i am getting "Root cause of JavaScriptException: java.lang.NullPointerException
: java.lang.NullPointerException:" error whose source is com.glide.ui.ServletErrorListener.

Code:-

JavaScript evaluation error on:
var data_string = source.u_whendisabled;
//convert date in .OZ format to sting
var when_disabled = data_string.substring(0,4)+'-'+data_string.substring(4,6)+'-'+data_string.substring(6,8)+' '+data_string.substring(8,10)+':'+data_string.substring(10,12)+':'+data_string.substring(12,14);

//set date based on US/Eastern time zone
var gDate = GlideDateTime();
gDate.setValue(when_disabled);

///substract offset based on time zone between UTC and US/Eastern
var offset = gDate.getTZOffset();
gDate.add(offset);

answer = gDate;
Root cause of JavaScriptException: java.lang.NullPointerException
: java.lang.NullPointerException:

Can some help me where can i find this this , whats the issue in this code and how can we resolve this?

Thanks!

 

6 REPLIES 6

Pranesh072
Mega Sage

Can you check value of "when_disabled" variable before this gDate.setValue(when_disabled).

 

I suspect there is some issue in line 2 code

var when_disabled = data_string.substring(0,4)+'-'+data_string.substring(4,6)+'-'+data_string.substring(6,8)+' '+data_string.substring(8,10)+':'+data_string.substring(10,12)+':'+data_string.substring(12,14);

This i found in the sys_transform_entry as a source script. the field u_whendisabled i mapped to user table AD disabled field. I think beacuse AD disabled is empty in the source table because of this error will come. am i right?

Its might be, the value is coming empty. You can always check by applying gs.log(source.u_whendisabled) or gs.info(source.u_whendisabled) in your script.

and 

instead of directly passing value you can use check the value

var data_string = source.u_whendisabled;
//convert date in .OZ format to sting
if(data_string!=''){
var when_disabled = data_string.substring(0,4)+'-'+data_string.substring(4,6)+'-'+data_string.substring(6,8)+' '+data_string.substring(8,10)+':'+data_string.substring(10,12)+':'+data_string.substring(12,14);

//set date based on US/Eastern time zone
var gDate = GlideDateTime();
gDate.setValue(when_disabled);

///substract offset based on time zone between UTC and US/Eastern
var offset = gDate.getTZOffset();
gDate.add(offset);

answer = gDate;
}	

var data_string = source.u_whendisabled;
//convert date in .OZ format to sting
if(source.u_whendisabled!="")
{
var when_disabled = data_string.substring(0,4)+'-'+data_string.substring(4,6)+'-'+data_string.substring(6,8)+' '+data_string.substring(8,10)+':'+data_string.substring(10,12)+':'+data_string.substring(12,14);

//set date based on US/Eastern time zone
var gDate = GlideDateTime();
gDate.setValue(when_disabled);

///substract offset based on time zone between UTC and US/Eastern
var offset = gDate.getTZOffset();
gDate.add(offset);

answer = gDate;
}

i have added "if(source.u_whendisabled!="")" in my code. is code looks ok now?