function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aryan JhaAryan Jha 

i have an error Variable does not exist: Match_Billing_Address__c at line 3 column 15

trigger AccountAddressTrigger on Account(Before insert,before update) {
 for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c == true && a.BillingPostalCode!=Null) {
            a.ShippingPostalCode = a.BillingPostalCode;
        }   
    }
}
VinayVinay (Salesforce Developers) 
Hi Aryan,

Check if 'Match_Billing_Address__c' field is existing on account?

Thanks,
Vinay Kumar
Aryan JhaAryan Jha
sir how we can check I am new in apex
VinayVinay (Salesforce Developers) 
Navigate to Setup--->Quick Find--->Account--->Fields.

User-added image

Please mark as Best Answer if above information was helpful.

Thanks,
Aryan JhaAryan Jha
Sir there is only billing address in the Account feild please give me some guidance for this
VinayVinay (Salesforce Developers) 
Then replace 'Match_Billing_Address__c' with 'BillingAddress'.  Since you do not have Match_Billing_Address__c field in your org.

Thanks,
Aryan JhaAryan Jha
Sir how can we change billing address to Matching_Billing_Address
VinayVinay (Salesforce Developers) 
You need to change in apex trigger (code which you have pasted above),  BillingAddress is a standard field you cannot change.

Thank,
Aryan JhaAryan Jha
SIR BUT QUESTION IS ASKED ON COUSTOM OBJECT
Aryan JhaAryan Jha
sir there is no option for change billing address to Match billing address
VinayVinay (Salesforce Developers) 
You would need a developer who can check and make above changes.  Kindly re-check on above inputs.

Thanks,
Sahithya Varanasi 12Sahithya Varanasi 12
Hi Aryan,

I hope you are doing well. Firstly, you need to head to setup mode. Select Accounts from object manager. Click on fields&relationships. Create a checkbox named Match Billing Address. Leave the checkbox unchecked.  After that, you need to write your trigger. 
The trigger is as follows: 

trigger AccountAddressTrigger on Account (before insert, before update) {
    for (Account a: Trigger.New) {
        if(a.Match_Billing_Address__c == True) {
            a.BillingPostalCode = a.ShippingPostalCode;
        }
    }
}

Once you save it, you can do some testing on the application and verify that it is working. When you populate just the shipping postal code field and check the match billing address, and save the record, you will see that the billing postal code would also be populated with the same postal code. 

Hope this helps!