• Amro Habib
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
so im trying to update all acoounts phone numbers, only when their Parent Account phone number is updated, but its not working, and my loop doesnt even iterate for some reason? whats wrong with code?

trigger UpdatePhoneNum on Account (before update) {

for(Account a : trigger.new)
{
if(String.isNotBlank(a.ParentId)){
Account acc = [SELECT Phone FROM Account WHERE Id = :a.ParentId LIMIT 1];
a.Phone = acc.Phone;
}
}
}
so im trying to update all acoounts phone numbers, only when their Parent Account phone number is updated, but its not working, and my loop doesnt even iterate for some reason? whats wrong with code?

trigger UpdatePhoneNum on Account (before update) {

for(Account a : trigger.new)
{
if(String.isNotBlank(a.ParentId)){
Account acc = [SELECT Phone FROM Account WHERE Id = :a.ParentId LIMIT 1];
a.Phone = acc.Phone;
}
}
}