- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2015 07:59 AM
Reminder Function
I'd like to create 2 time-based email notification reminders. Both will trigger when the analyst picks a date & time from a custom field on the u_table called 'Reminder'. This field will be a date\time type. The table called 'u_table' extends from the 'Task' table.
When counting down to the future input date the 'state' field on the 'Task' table should automatically be set to 'On hold'. After the future input date has been reached and has passed, the 'state' should automatically change to 'Open'.
1). Reminder triggers when a future input date (or date\time) is reached. e.g. input date: 28/06/2016 10:00 (26th June 2016 10am) | Email notification reminder sent to 'Assigned to' on 26th June 2016 10am
2). Reminder triggers 1 month before the future input date (or date\time) is reached. e.g. input date: 28/06/2016 10:00 (26th June 2016 10am) | Email notification reminder sent to 'Assigned to' on 26th May 2016 10am
This seems to me to be something that someone may of done already, so I'd appreciate any examples and knowing the best way to accomplish this?
So far I've seen suggestions of using a script with a scheduled job combined with Scripts Include or using sla's https://community.servicenow.com/message/798732#798732 but unanswered solution.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2015 01:17 AM
If the requirement needs to have a accurate reminder then the above script can be used else a scheduled job would suffice your requirement. When I say accurate, I am meaning that would need to ignore the time value of the field if it is a datetime field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 04:09 PM
I had no joy understanding what I was supposed to do with that script, due to not playing with scheduled jobs before and I could could see how I'd trigger the OnHold state either. However I did come across an extremely basic way of setting a reminder based on http://wiki.servicenow.com/index.php?title=Notification_Examples#gsc.tab=0
So now I have the following example below which works ok but does not trigger the On Hold state:
Reminder field on table
Column Label: Reminder
Column Name: u_rem
Type: Date/Time
Table: e.g 'u_rem'
Active: ticked
Business Rule
Name: 'myReminder'
Table: e.g 'u_rem'
Advanced: ticked | Active: ticked | When: After | Insert: ticked | Update: ticked | Order: 100
Condition: current.u_rem.changes()
Script: gs.eventQueueScheduled("my.reminder", current, gs.getUserID(), gs.getUserName(), current.u_rem);
Event Registry
Event Name: my.reminder
Table: e.g 'u_rem'
Fired by: myReminder
Email Notification
Name: my.reminder
Table: e.g 'u_rem'
Type: Email (in advanced view only) | Active: ticked
Send When: Event is fired
Event Name: my.reminder
Conditions:
Reminder(u_rem) | at or after | Today
or
Reminder(u_rem) | is not empty
Who will receive
Users/groups in fields: Assigned to
What will it contain:
From: email@email.com
Subject: Your Reminder etc
This solution does not trigger the On Hold state and I haven't figured how to make the notification trigger 30days before the input date. Any help on either developing this or how other options could achieve this. I've not looked into scheduled jobs or scheduled job scripts but willing to give a try if a better way to accomplish this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 04:56 PM
I had something similar. User inputs due_date and email should trigger when due_date comes due. You could do a 2nd script or add on to the if statement, but you have to use seconds. This is in a scheduled job that runs every 5 minutes.
var gr = new GlideRecord('incident');
gr.addQuery('active', true); //only send reminders on active tasks
gr.addQuery('due_date', '!=', ''); //just get those with due date populated..
gr.query();
while (gr.next()) {
var gtnow = gs.nowDateTime();
var display = gr.due_date.getDisplayValue();
var gtreq = GlideDateTime(display);
var diff = gs.dateDiff(gtreq, gtnow, true);
//gs.log("different: " + diff + ' - ' + gr.number);
if (diff > 0 && diff < 300){
gs.eventQueue("incident.due_date", gr, gs.getUserID(), gs.userName());
gs.log(' Scheduled job - Monitor for due_date on Incident email sent ' + gr.number + ' - ' + display);
}
else {
//gs.log(' Scheduled job - Monitor for due_date on Incident ');
}
}