trigger an email for birthday from the table by comparing dob field with current day and month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 02:06 AM
We need to trigger an Email notification for Birthday for the user from the 'sys_user' Table . We need to compare only day and month of the dob field and comparing with current day and month and email need to send for that user's email id. help me with the complete process and code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 02:19 AM
Hello @Varma0326
You can create a Occasion and Link it with Notification :-
Plz go through the below link :-
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 03:58 AM
HI @Varma0326 ,
I trust you are doing great,
Please find the below script for the same
// Get the current date and month in the format '00-MM-DD'
var currentMonthDay = '00-' + (new GlideDate().getMonthDay());
// Query the sys_user table for users with matching birthday
var userGR = new GlideRecord('sys_user');
userGR.addQuery('dob', 'LIKE', currentMonthDay);
userGR.query();
// Loop through the users and send the birthday notifications
while (userGR.next()) {
var recipientEmail = userGR.email.getDisplayValue();
var emailTemplate = 'TEMPLATE_NAME'; // Replace 'TEMPLATE_NAME' with the name of your created email template
gs.eventQueue('birthday.notification', userGR, emailTemplate, recipientEmail);
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi