• yaseen sultan 6
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi Team,

I am trying to write a triiger when an account email is updated i want to update contact email as well. 
can you help me in achevie this from trigger .

trigger accountemailupdated on account(before insert,before update){
List<account> emailnew = new List<account>();
set<id> idvalue = new set<id>();
{
for(account a : trigger.new){
idvalue.add(a);
}
emailnew = [select id,name,email (select id,email from contacts) form account where account id in:idvalue]

for(contacts c :emailnew.accountid){
contacts con = new contacts();
if(emailnew.accountid==con.accountid)
{
con.email = emailnew.email;
}
update emailnew;
}