Skip to main content
1 answer
  1. Jul 18, 2025, 11:51 AM

    @Prapti Saxena

    - Check the below code 

     

    trigger AccountAddressTrigger on Account (before insert, before update) {

    for (Account acct : Trigger.new) {

    // 1) Skip every record where the checkbox isn’t checked

    if (!acct.Match_Billing_Address__c) {

    continue;

    }

    // 2) On update, only act if it just flipped from false → true

    if (Trigger.isUpdate) {

    Account oldAcct = Trigger.oldMap.get(acct.Id);

    if (oldAcct.Match_Billing_Address__c) {

    // it was already true before, so skip

    continue;

    }

    }

    // 3) Now we know Match_Billing_Address__c is true (newly checked or on insert)

    // and we can safely copy the Billing postal code over

    acct.ShippingPostalCode = acct.BillingPostalCode;

    }

    }

0/9000