• Disha Thakur
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
trigger BirthdateTrigger on Account (after insert, after update) {
List<Account> acc= new List<Account>();
    if(trigger.isInsert || trigger.isUpdate)
{
    acc = [select Id,(select Birthdate from Contacts ORDER BY CreatedDate DESC LIMIT 1) from Account where Id IN :trigger.new];
     for(Account a : acc)
     {
         for(Contact c : a.Contacts)
         c.Birthdate = Date.newInstance(2000,06,12);
         System.debug('Birthdate updated');
     }
}
}