Hello everyone, iam trying to send birthday notification using schedueld job but its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 10:17 PM
var today = new GlideDateTime();
var currentMonth = today.getMonth();
var currentDay = today.getDayOfMonth();
gs.info("Current Month: " + currentMonth);
gs.info("Current Day: " + currentDay);
var gr = new GlideRecord('sys_user');\
gr.addActiveQuery();
gr.query();
while (gr.next()) {
var dob = new GlideDate(gr.u_date_of_birth);
//var dob = gr.u_date_of_birth;
var dobMonth = dob.getMonth();
gs.info("dob" + dob);
gs.info("dobMonth" + dobMonth);
var dobDay = dob.getDayOfMonth();
gs.info("dobDay" + dobDay);
if (dobMonth == currentMonth && dobDay == currentDay) {
var user = gr.getDisplayValue('name');
var email = gr.email;
gs.eventQueue('birth.day', gr, email, user);
}
}
here we iam trying to get current month and date but not the year so it matches the month and date the notification should be trigger to user.
Root cause of JavaScriptException: java.lang.NullPointerException
: java.lang.NullPointerException: java.base/java.util.Calendar.setTime(Calendar.java:1800)
com.glide.glideobject.GlideDateTime._getMonth(GlideDateTime.java:1862)
iam getting this error please help with the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 10:46 PM
The custom field u_date_of_birth is of type datetime or it is a string field ?
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 09:36 PM
u_date_of_birth type is Date type and tried using date and time to but no luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 10:30 PM
Did you got a chance to look on the below post. It will be a pure no-code and efficient approach :
https://www.servicenow.com/community/itsm-forum/birthday-email-notification/td-p/669497
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 10:36 PM
Can you try this once-
var dob = new GlideDateTime(gr.u_date_of_birth);
Also, would recommend you to use flow designer. The link shared my Mr. @Amit Verma will help you configure that.
Regards,
Amit