0

I've been trying to complete a challenge on trailhead (link here)

The text says "Create an Apex trigger that sets an account’s Shipping Postal Code to match the Billing Postal Code if the Match Billing Address option is selected. Fire the trigger before inserting an account or updating an account. "

So I wrote this code:

trigger AccountAddressTrigger on Account (before insert, before update) {
    for (Account item : Trigger.new) {
        if (item.Match_Billing_address__c) {
            // ?
        }
    }
}

I tried looking up in the schema builder or anywhere really any information about what field to use in order to get the shipping and the billing postal code in order to update them but I couldn't find it anywhere.

I had to google the answer and found someone who suggested adding

item.ShippingPostalCode = item.BillingPostalCode;

My question is: Why? How do I know that ShippingPostalCode and BillingPostalCode are a thing?

Thanks in advance for your help

2
  • Both fields are listed in the Object Reference docs.
    – TSmith
    Apr 25, 2022 at 9:31
  • thank you @TSmith. Exactly what I was looking for. Is there any way to access the information from the object manager, schema builder or similar? Or do I always just refer to the docs?
    – Frans
    Apr 25, 2022 at 9:35

1 Answer 1

0

You will notice that these fields on Account (and other standard objects) are compound fields. This means we cannot see the breakdown using Schema Builder but rather rely on the documentation (see Account docs) and also page layouts if you really wanted to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .