To send notification in regular interval of time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:36 AM
Hi All,
I have a requirement where i want to generate an email notification for regular interval of time for every 5 years until the ticket is closed. However the Date will remain same but the email must be getting triggered for every 5 years based on Date present in the field (Date can vary according to ticket creation).
Can someone please guide me how can i solve this.
Field type - Date
Field Name - Service Plan (u_service_plan)
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:45 AM
you can use scheduled job for this flow which runs daily
what did you start with and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:47 AM
something like this
var gr = new GlideRecord('your_table_name');
gr.addQuery('state', '!=', 'closed'); // Ensure the ticket is not closed
gr.query();
while (gr.next()) {
var ticketDate = new GlideDateTime(gr.getValue('u_service_plan') + ' 00:00:00');
var currentDate = new GlideDateTime();
var fiveYearsAgo = currentDate.subtract(5 * 365 * 24 * 60 * 60 * 1000); // 5 years in milliseconds
if (ticketDate.compareTo(fiveYearsAgo) <= 0) {
gs.eventQueue('your_custom_event', gr, recipientEmail);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 08:19 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2025 11:30 PM
Hi @Ankur Bawiskar , apologize
The above code is not working for me.
Below i have shared the scheduled job script for repeated interval of time and field name and its type. Can you please help me with this where i'm wrong.