+ Start a Discussion
andy_hudsonandy_hudson 

Apex Code, Task Trigger

Hi all

 

I have created a Task Manager application and I am having some problem surrdoung the Due Date.  I want to implement two pieces of functionality:

 

  • When selecting a due date the user can only selected dates that are in the future.  They can't selected a past date.  EG if it is the 30/09/11, they can't select 28/09/11.
  • I am also looking to set up Due Date reminders, so when a task in coming or a few days a way they either recieve a pop-up message on salesforce or an email.  I know this functionality exists in the other Task app already in Salesforce, but how do I get it into my app?

Any help would be much appreciated

 

Many thanks

 

Andrew Hudson

KaranrajKaranraj

Write a task trigger 

trigger testTrigger on Task (after insert, after update) 

{
for(Task task: Trigger.new)
{
 Datetime createddate =task.CreatedDate;

 if(task.Activitydate <  createddate.date())

 {

   task.Activitydate.addError('Due date must be greated than created date');

 }
}
}
This code will restrict the user to select the prior value in the due date.
If this solve your issue,mark it as answer