How to check the due date is seven days from now for a ticket

Tamilvanan T
Tera Contributor

How to create a script to check the due date is seven days from now for a ticket and trigger a reminder notification using the schedule job.

4 REPLIES 4

Dr Atul G- LNG
Tera Patron

Hi @Tamilvanan T 

 

use flow designer:

 

https://www.servicenow.com/community/developer-forum/flow-designer-reminder-emails/m-p/2413189

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron

@Tamilvanan T 

I shared working solution few years ago using flow designer with 3 days, you can enhance it for 7 days

how to send email notifications prior or 3 days befor valid date automatically 

sharing again here

Do remember to save and Activate the Flow

example below:

AnkurBawiskar_0-1767789468748.png

 

AnkurBawiskar_1-1767789468749.png

 

AnkurBawiskar_2-1767789468712.png

 

AnkurBawiskar_3-1767789468735.png

 

 

AnkurBawiskar_4-1767789469931.png

 

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Tamilvanan T 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

VaishnaviK43271
Tera Contributor

Hi @Tamilvanan T !!

You can achieve this by using a Scheduled Script Execution that checks records whose Due date is exactly 7 days from today and then triggers a notification (event).

 

1)Create a Scheduled Script Execution

Navigate to:
System Definition → Scheduled Jobs → Scheduled Script Executions

  • Run: Daily (recommended)

  • Active: ✔

2) Scheduled Job Script Example

(function () {

    var gr = new GlideRecord('task'); // or incident/change/etc
    gr.addNotNullQuery('due_date');

    // Due date exactly 7 days from now
    var start = gs.daysAgoStart(-7);
    var end = gs.daysAgoEnd(-7);
    gr.addQuery('due_date', '>=', start);
    gr.addQuery('due_date', '<=', end);

    gr.query();

    while (gr.next()) {
        // Trigger event for notification
        gs.eventQueue(
            'task.due.reminder',
            gr,
            gr.assigned_to,
            gr.number
        );
    }

})();

 

  • This checks for records whose due date is 7 days from today
  • Runs once per day
  • Avoids duplicate reminders if scheduled correctly

3) Create an Event

Go to:
System Policy → Events → Registry

  • Name: task.due.reminder

  • Table: task

4) Create a Notification

Navigate to:
System Notification → Email → Notifications

  • Table: task

  • When to send: Event is fired

  • Event name: task.due.reminder

  • Recipients: Assigned to / Group / Manager (as required)

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for.

Thank You