Automatically Populate the Primary County Field Based on the Entered ZIP Code¶
This guide covers configuring a field that automatically populates with the county corresponding to the entered ZIP code. It applies to United States addresses only, and this example uses the Account object.
Creating the Necessary Lookup Fields¶
Create the three necessary lookup fields for the address block: Country Lookup, State Lookup, and ZIP Code Lookup. See Create Lookup Fields.
After creating these fields, enable lookup field population:
- Go to AddressTools Administration > Settings.
- Click the pencil icon next to Enable Field Lookup Population.
- Select the Enable Field Lookup Population checkbox.
- Click Save.
Add the lookup fields to the address block:
- Go to AddressTools Administration > Address Blocks.
- Select the dropdown arrow next to the relevant address block and click Edit.
- Under the Lookup Fields section, select the fields created above.
- Click Save.
Creating a Formula Field to Display the County¶
- Navigate to Setup > Object Manager > [Object you are using].
- Select Fields & Relationships > New.
- Select Formula, then click Next.
- Name the field, choose Text as the return type, then click Next.
- Select Advanced Formula, then Insert Field.
- Select [Object you are using] > [ZIP Code Lookup field created above] > Primary County.
Note: Configure the field-level security for this field and add it to the page layout to meet the org's requirements.
With the formula field created and on the page layout, when a record is saved with a valid US ZIP code, the value from the associated county record appears in the formula field.