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
lonely boylonely boy 

task reminder - notification to mark the task complete sent to the current owner of the task after a specified time period

VinayVinay (Salesforce Developers) 
Hi,

Check below example for custom email notification for completed tasks

https://automationchampion.com/2022/03/10/custom-email-notification-for-completed-tasks-2/

Also there is a limitation around email notification for task creator.

https://ideas.salesforce.com/s/idea/a0B8W00000GdmP0UAJ/send-email-notification-for-completed-tasks-to-task-creator

Please mark as Best Answer if above information was helpful.

Thanks,
Arun Kumar 1141Arun Kumar 1141
Hi @lonely boy,

Here's the solution for your question using Trigger.

Trigger =>
 
trigger DevQ2Trigger on Task (before insert,before update) {
DevQ2.ans(Trigger.new);
}


Handler Class =>

    
public class DevQ2 {
    
    public static void ans(List<Task> tList){
        
       for(Task t:tList){
            if(t.status == 'Completed'){  
                User owner = [Select name,email from user where id =:t.ownerId limit 1];
                
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                
                email.setToAddresses(new String[]{ owner.Email });
                email.setSubject('Reminder: Task "' + t.Subject + '" is completed');
                email.setPlainTextBody('Dear ' + owner.Name + ',\n\nThis is a friendly reminder 
                that the following task is now completed:\n\n' + t.Subject);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
            }
        }
    }
}

Hope this is helpful.

Thank you.