- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 10:08 AM
Hi,
I need to send notification on employee work anniversary.
To achieve that I have created :
1. Event
2. Schedule Job
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 12:12 AM - edited 12-16-2024 12:37 AM
Hi @niveditakumari ,
Adjusted the code to below as I wasn't aware that your "Date Of Joining" field was not a date field.
var gr = new GlideRecord("sys_user");
gr.addQuery("active=true^u_date_of_joiningISNOTEMPTY"); // Query for active users with a joining date
gr.query();
while (gr.next()) {
var jdate = new GlideDateTime(gr.u_date_of_joining); // Parse u_date_of_joining
var to_date = new GlideDateTime(); // Current date
gs.print(jdate.getDayOfMonth());
// Compare day and month
if (to_date.getMonthUTC() == jdate.getMonthUTC() && to_date.getDayOfMonth() == jdate.getDayOfMonth()) {
gs.print("Hi, it's the user's joining date anniversary!");
gs.eventQueue("joining.notification", gr, gr.name.toString(), gr.email.toString());
}
}
Please try using this script and let me know if there are any further issues.
Please mark this solution as "Helpful" and "Accepted Solution" if this solution helped you in any way.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 12:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 01:02 AM
seems the field is empty for the user record
are you sure the field name is correct?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 11:00 PM
Hi @niveditakumari ,
You can use a schedule job to achieve your requirement.
To test click on "Execute Now" button and verify whether emails are triggered.
Ensure your notification is triggered when event is fired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 03:08 AM
Hi @shivatmika_19,
Can you please confirm how you have calculated years like in preview email it is showing Congratulations on Amazing 2 years, Abel Tutor.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 10:15 PM
Hi @niveditakumari ,
I used an email script for that.
Use ${mail_script: email script name} where ever you require in the notification body