- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2016 01:06 PM
I am trying to run a script include that will skip the weekend. I keep receiving an error on getDayOfWeek()
java.lang.NullPointerException
function checkDate(x) {
var gdt = new GlideDateTime(x);
var day = gdt.getDayOfWeek();
if (day == 1) {
return gdt < gs.daysAgo(3);
} else {
return gdt < gs.daysAgo(1);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2016 02:16 AM
HI sigmachiuta,
I doubt on the parameter(x) value, that you are passing to the GlideDateTime(x) class.
var gdt = new GlideDateTime('invalid date time format');
var day = gdt.getDayOfWeek();
The above code will produce null pointer exception. So, try adding log statements and check once?
gs.log("x vlalue is"+x);
var gdt = new GlideDateTime(x);
var day = gdt.getDayOfWeek();
Cheers
Srini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2016 02:16 AM
HI sigmachiuta,
I doubt on the parameter(x) value, that you are passing to the GlideDateTime(x) class.
var gdt = new GlideDateTime('invalid date time format');
var day = gdt.getDayOfWeek();
The above code will produce null pointer exception. So, try adding log statements and check once?
gs.log("x vlalue is"+x);
var gdt = new GlideDateTime(x);
var day = gdt.getDayOfWeek();
Cheers
Srini