scheduled job to send reminder 5 days after creation of a task

david_2508
Tera Contributor

Hi,

I would like to create a scheduled job to send a reminder by notification 5 days after a task was created.

This notification must be send only one time after 5 days.

I don't find how I can do that.

Could someone help me to solve this issue, please ?

Here is my scheduled job :

send1streminder();

function send1streminder() {

var task = new GlideRecord('sc_task');

task.addQuery('short_description', 'receive draft');

task.addQuery('active', 'true');

task.addQuery('sys_created_on', '=', gs.daysAgoStart(5));

task.query();

  while(task.next()){

  gs.eventQueue('bg.1st.reminder', task, gs.getUserID(), gs.username());

  }

}

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

I'm assuming everything is working except the 'repeat check', correct?



If you want to ensure it is only sent one time, add a true/false field to your sc_task table (default=false). This script will set the value to true when it is set. Then update your script to look for only those records where the value is false (so it doesn't resend to records that are true.)



task.addQuery('u_reminder_sent', false);


View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

I'm assuming everything is working except the 'repeat check', correct?



If you want to ensure it is only sent one time, add a true/false field to your sc_task table (default=false). This script will set the value to true when it is set. Then update your script to look for only those records where the value is false (so it doesn't resend to records that are true.)



task.addQuery('u_reminder_sent', false);


Requirement is Scheduled jobs through trigger Notifications, only create in scheduled jobs not flow designer or workflow

Like day1&3&6&10 trigger the notifications those days.

 

Any idea how to build the logic please let me know

amaradiswamy
Kilo Sage

you can create a field like 5 days reminder in task table and update from the script and the schedule jo include the condition like 5daysreminder is false.



Thanks and regards,


Swamy


david_2508
Tera Contributor

Hi Chuck and Swamy,



Thanks for your answer. I had the same idea but I hoped that it was possible to add a condition in my scheduled job to select only tasks created since 5 days. You can use the operators <,>,>=,<= but not = or == for a date field.