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
Swamy NarenSwamy Naren 

Get Started with Apex Triggers

Hi All, 

I am getting following error message: 

Challenge not yet complete... here's what's wrong:
A field with an API Name 'Match_Billing_Address__c' does not exist on the Account object

my code is as follows:


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

 Thanks in Advance
Best Answer chosen by Swamy Naren
Khan AnasKhan Anas (Salesforce Developers) 
Hi Swamy,

I trust you are doing very well.

Please follow below steps:
  • Create a custom field: Setup-> Object Manager-> Account -> Fields and Relationships 
  • Select New --> Field Type (Checkbox)
  • Enter Name as Match Billing Address 
  • Checkbox  should be Unchecked 
  • Save.
Now write the below code, it is working without any errors
trigger AccountAddressTrigger on Account (before insert , before update) {
    for(Account acc:Trigger.New){
        if(acc.Match_Billing_Address__c && (acc.BillingPostalCode != null || acc.BillingPostalCode!=' ' )){
           acc.ShippingPostalCode = acc.BillingPostalCode;
        }
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas

All Answers

GulshanRajGulshanRaj
Please visit setup->account and check if "Match_Billing_Address__c" field is created or not. If not, create it.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Swamy,

I trust you are doing very well.

Please follow below steps:
  • Create a custom field: Setup-> Object Manager-> Account -> Fields and Relationships 
  • Select New --> Field Type (Checkbox)
  • Enter Name as Match Billing Address 
  • Checkbox  should be Unchecked 
  • Save.
Now write the below code, it is working without any errors
trigger AccountAddressTrigger on Account (before insert , before update) {
    for(Account acc:Trigger.New){
        if(acc.Match_Billing_Address__c && (acc.BillingPostalCode != null || acc.BillingPostalCode!=' ' )){
           acc.ShippingPostalCode = acc.BillingPostalCode;
        }
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
This was selected as the best answer
Niraj Kr SinghNiraj Kr Singh
Hi Swamy,

Looks like you do not have "Match_Billing_Address__c" this field on Account object.
Create this field on account as boolean type and then check with new Account creation.

 
Swamy NarenSwamy Naren
Thank you all
Actually i forgot to give space between MatchBillingAddress