function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam.arjSam.arj 

Setting the reminder of recurring Tasks

When creating a recurring task using Apex, how I can set the reminder to get the same functionality as what UI offers?

 

The Task object has only a "ReminderDateTime"! 

 

Task t = new Task();

t.Subject = 'Test';

t.IsReminderSet = true;

t.RecurrenceType = 'RecursEveryWeekday';

t.RecurrenceDayOfWeekMask = 62;

t.ReminderDateTime = ??   //this is a date time field, How to set to : "On occurrence date" at "8:00 am" for each occurrence? 

 

insert t;

 

 

krprkrpr

ReminderDateTime should be in the Date Time Format.

Sam.arjSam.arj

Hence why I have this question!!

 

How I can set the reminder for the recurring task?

krprkrpr

For ex : Datetime myDate = Datetime.valueOf('2013-06-14 15:15:15');

 

assign myDate to  ReminderDateTime

 

 

krprkrpr

'YYYY-mm-dd hr:min:sec'

Sam.arjSam.arj

Not sure how to make myself clear:

See the picture below, when setting the reminder for recurring Task, options are different:

krprkrpr

This should help you .

 

Datetime myDate = Datetime.valueOf('2013-06-14 15:15:15');

task tasks = new task();
tasks.IsRecurrence = true;
tasks.RecurrenceStartDateOnly = date.newinstance(2013, 6, 17);
tasks.RecurrenceEndDateOnly = date.newinstance(2013, 7, 17);
tasks.RecurrenceType = 'RecursDaily';
tasks.RecurrenceInterval = 3 ;
tasks.IsReminderSet = true;
tasks.ReminderDateTime = myDate;

insert tasks;



Sam.arjSam.arj

Thanks for your response.

 

So If I want to set the reminder to:

 

  notify me: 3 days before each occurance at 10:30 AM

  

  What should I set in the DateTime value? 

  Just to understand the logic.

 

  If I was to set the DateTime value for one time reminder, I already know how one can set a DateTime value in Apex.

krprkrpr

Try this :

 

Datetime myDate = Datetime.valueOf('2013-06-24 10:30:15');

task tasks = new task();
tasks.IsRecurrence = true;
tasks.RecurrenceStartDateOnly = date.newinstance(2013, 6, 27);
tasks.RecurrenceEndDateOnly = date.newinstance(2013, 7, 17);
tasks.RecurrenceType = 'RecursDaily';
tasks.RecurrenceInterval = 3 ;
tasks.IsReminderSet = true;
tasks.ReminderDateTime = myDate;

insert tasks;