You need to sign in to do that
Don't have an account?

How to trigger the email notification to the task owner for the task update by Apex Coding?
Hi,
I'd like to set up the email notification for the task update. Once the Comments or Status field in the existing task has been updated by someone else, it can trigger the email notification to send to the task owner. Can it be done by the Apex Coding?
I'd like to set up the email notification for the task update. Once the Comments or Status field in the existing task has been updated by someone else, it can trigger the email notification to send to the task owner. Can it be done by the Apex Coding?
Yes, you can absolutely accomplish this with an apex trigger, HOWEVER, I would recommend using a Workflow. It will be a lot easier to implement and maintain.
Goog luck!
Thanks for your reply. I have tried to create a workflow and added the action as the email alert to get it done, but there is no option for the Task in the object selection list under the Email Alert.
You can use trigger to notify user using Trigger, below is sample code
Please update Email subject & body content as per ur need.
Thanks
You are correct. Sorry about that.
Let me make it up to you, here is a trigger that might work for you.
Two ways you can add
1) Eclipse - create new trigger
2) go to Customize --> Activities --> triggers -- click on New
3) Open Developer console - you will find File, Edit, debug
Select File --> New --> apexTrigger
give the trigger name and select the task__c as sObjectType
1) I cannot find this path in our current system.
2) There is no New option for me to add the trigger.
3) The only sObjectType in the list is "Task". I typed the name and selected "Task" and got the error "Can not create Apex Trigger on an active organization".
Please help. Thanks.
I copied the codes you made for me to the Sandbox and tried to update the comments field of the exisitng task. Then I got the error message as follows:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger trgTask_EmailOwnerOnComplete caused an unexpected exception, contact your administrator: trgTask_EmailOwnerOnComplete: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.trgTask_EmailOwnerOnComplete: line 4, column 1
Can you help to take a look into it?
Thanks,
Amber
Please make sure that you replace the "ENTER Email Template API NAME HERE" with the name of the email template that you would like to use. If you dont have one, create the template and then set the name on the code.
I have changed the statement to replace the email tamplate
EmailTemplate template = [SELECT id FROM EmailTemplate WHERE DeveloperName = 'TaskUpdate'];
When I tried to change the status to the Completed, I got another error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger trgTask_EmailOwnerOnComplete caused an unexpected exception, contact your administrator: trgTask_EmailOwnerOnComplete: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: []: Trigger.trgTask_EmailOwnerOnComplete: line 24, column 1
Another question, can you also include the update of the Comments in the triggers?
Thank you,
Amber
Thanks!!
Shannon
Thanks!
Stacy