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
Test User 1040Test User 1040 

email alert using trigger on field update on account object

Hi,

I'm new to salesforce apex. I had a requirement, where i need to write a handler class and trigger for email alert notification within account object.
I'm having two custom lookup fields, if any one of the field is updated then email has to be triggered to the owner and the assosiated roles as well.Can any one help me with the code. Thank you in advance.Its urgent please.
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You don't need a trigger for this, this can be achieved through a simple Workflow Rule or process builder.

Assuming you have access to workflow rules, you will have to do the below:
  • Create a Workflow rule on the Account Object
  • Evaluation Criteria: Created and every time it's edited
  • Rule Criteria formula evaluates to True and the formula is ISCHANGED(Your_Field_Name)
  • Use the insert field button to select the field API Name of your field
  • Immediate Action: Email Alert
  • Select your Template (Create one if you don't have the template created)
  • Select the recipient
  • Save, Done and Activate the Workflow rule.

Still, if you need trigger then I suggest you Please refer to the below links with a similar discussion which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/38947/sending-email-notification-using-trigger

https://developer.salesforce.com/forums/?id=906F0000000AZRAIA4


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas