• Akshat Ajmera
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi Guys,
I'm doing a hands-on exercise on triggers. The requirement is:
When a Billing Address is modified in accounts, get the new Postal Code. Then check which Contacts on the Account are outside that Postal Code. If 1 or more Contacts are outside of the Postal Code, mark Out_of_Zip as TRUE.

I've written the below trigger but the Out_of_Zip field is not getting updated. I'm not sure how to check if the trigger is firing or not.
Can someone tell me where to check the logs for triggers ?

trigger OutOfZipTrigger on Account (before update) {
    for(Account a: trigger.new){
        Account oldAccount = Trigger.oldMap.get(a.id);
  if(a.BillingAddress != oldAccount.BillingAddress )
    {
       List<contact> con = [select id,MailingPostalCode from contact where accountId =: a.id] ;
        for(contact c: con){
    if(a.BillingPostalCode != c.MailingPostalCode){
              a.Out_of_Zip__c = True;
               //acc.add(a);
           }
       }
    }
    }
}