How to Create a Reminder Function

tech_tc
Mega Contributor

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.

1 ACCEPTED SOLUTION

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.


View solution in original post

6 REPLIES 6

Kalaiarasan Pus
Giga Sage

More than few ways discussed here.. Choose the method that suits you



Re: What's the best way in FUJI to send approval reminders


Kalaiarasan



I had a look at your post which i think may work for me.


https://community.servicenow.com/message/737458#737458




var today = new GlideDateTime();


var sched = new ScheduleOnce();


sched.script = "gs.log('Checking Schedule Once');";


sched.setTime(today);


sched.setLabel("Demo Job : Run Once");


sched.schedule();



Does the above script sit inside a 'Scheduled Script Execution? I've not create a schedule job before, so not sure how this all hangs together.


Hi Tony Campbell,



No. Actually that script will go in any server side script (for instance... a business rule) that could automatically generate a scheduled job. The script that it's going to execute is going to be the one assigning to the script property in the following line:


sched.script = "gs.log('Checking Schedule Once');";


In other words, the above script you shared only automates the creation of a scheduled job.



If you already know the script that you will like to executed on a recurrent basis then you don't need to automate the creation of a scheduled job per reminder. That may be an overkill. You just need to add that script that takes care of iterating through the reminders in your custom table in a scheduled job.  



For your specific requirement I can see you have two options:



a) a scheduled job that runs once a day and takes care of sending all the reminders


b) a workflow that based on your input fields takes care of sending out the notification using the timers available in the workflows activities.



I hope this is helpful!



Thanks,


Berny


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.