How to check the due date is seven days from now for a ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
