Create Custom Address Fields¶
Overview¶
An address block needs five fields to describe an address: street, city, state, country and postal code. On Account, Contact, Contract and Lead these already exist as standard Salesforce fields, so there is nothing to create. On a custom object, or where you want a second address on a standard object, you create them yourself.
AddressTools expects each of the five to use a particular data type. Read this page even if the fields already exist, so you can check the types are right before you bind the block.
You can either create five individual fields, or use the single Salesforce Address compound field. We recommend separate fields as Salesforce's Address field type restricts the country and state values to its own picklists, which affects some AddressTools features.
Note: You can only use the singular Salesforce Address field if you have turned on the User Interface setting Use custom address fields in your org.
The Fields to Create¶
| Field Label | Data Type | Length |
|---|---|---|
| Street | Text Area | 255 |
| City | Text | 255 |
| State | Text | 255 |
| Country | Text | 255 |
| Postal Code | Text | 255 |
Street uses Text Area rather than Text so that an address can run to more than one line. The other four hold a single value each.
Step 1: Create Each Field¶
Repeat these steps five times, once per row of the table above.
- Navigate to Setup > Object Manager.
- Select the object, then select Fields & Relationships.
- Click New.
- Choose the data type for the field you are creating and click Next.
- Enter the Field Label.
- Set Length to
255. - Click Next.
- Provide visibility to all the users who will be verifying addresses, then click Next.
- Add the field to the page layouts where the address should appear, then click Save.
Note: Name the fields after the address they belong to if the object holds more than one, for example Site Street and Site City. It keeps the picklists readable when you come to map the block.
Step 2: Bind Them to an Address Block¶
The five fields above are all AddressTools needs to validate and standardise an address. For instructions on how to map them in the Postal Address Fields section of an address block, see Binding an Address Block.