0

Trying to learn Apex, walking through this Trailhead. Here is description and then my attempt, getting this error:

Variable does not exist: Match_Billing_Address__c

Description:

The Apex trigger must be called AccountAddressTrigger.

The Account object will need a new custom checkbox that should have the Field Label Match Billing Address and Field Name of Match_Billing_Address. The resulting API Name should be Match_Billing_Address__c.

With AccountAddressTrigger active, if an Account has a Billing Postal Code and Match_Billing_Address__c is true, the record should have the Shipping Postal Code set to match on insert or update.

My attempt:

    trigger AccountAddressTrigger on Account (before insert, before update) {
    for ( Account a : Trigger.new ) {
        if ( a.BillingPostalCode != NULL && a.Match_Billing_Address__c == true ){
            a.ShippingPostalCode = a.BillingPostalCode;    
        }
    }
}
  • 3
    You must have missed creating a Boolean field on Account object called Match_Billing_Address__c – Vijay Ganji Aug 19 '19 at 14:36
  • You definitly missed creating boolean field, also the code can be simplied as if ( a.BillingPostalCode != null && a.Match_Billing_Address__c ){ – Pranay Jaiswal Aug 19 '19 at 14:40
  • True... thanks, I´m stupid – Manuel Aug 19 '19 at 14:50
0

I think you have just missed to create a boolean field on account as mentionned :

The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.