+ Start a Discussion
AniltAnilt 

Reminder has to Popup before 30 minutes of the Due Time

Hi Everyone,

 

I've a datetime field in 'Due_Date_Time__c' which will update another field "ReminderDateTime" with the following code (Subtracting 30 minutes from the Due_Date_Time__c).

 

Task t = new Task();
t.Subject='Send an Email';
t.Status= 'In Progress';
t.IsReminderSet= true;
t.priority='Normal';
t.Due_Date_Time__c=DateTime.Now().adddays(2);
t.Reminderdatetime=t.Due_Date_Time__c-(1/48); //formula to update reminderdatetime field
System.debug('Reminder Date Time is' + t.reminderdatetime);
System.debug('Due Date Time is' + t.Due_Date_Time__c);
database.insert(t);

 

So here the problem is I'm getting the reminderdatetime and due date time values as same.

Note: I want to integrate this in the clients website..So cant go for workflow.

 

Please help me where I'm doing wrong.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
AniltAnilt

I've got the answer

 

Task t = new Task();
t.Subject='Send an Email';
t.Status= 'In Progress';
t.IsReminderSet= true;
t.priority='Normal';
t.due_time__c=System.Now().adddays(2);
t.Reminderdatetime=t.Due_Time__c-0.02083; //1/48=0.02083..have to keep this 0.02083 rather than 1/48
System.debug('Reminder Date Time is' + t.reminderdatetime);
System.debug('Due Date Time is' + t.Due_Time__c);
database.insert(t);