Newer Version Available
Custom Address Fields
Use the Address field type to create custom fields that store address data in a
structured compound data type. Compound fields are an abstraction that can simplify application
code that handles the values, leading to more concise, understandable code. With Custom Address
Fields, custom addresses are accessible as a single, structured field, or as individual
component fields.
| Available in: all editions |
Address compound fields are delivered for standard fields on standard objects. Now with
Custom Address Fields, custom fields can mirror the standard address field behavior. End users
can add and retrieve address data via these custom Address fields on standard and custom
objects. Users can edit the custom address field data in records and view custom address data
in list views and reports.
Supported Features and Functionality
Custom Address Fields supports these features.
- Google Address Lookup
- When users populate a custom address field, they can enter an address manually or they can use the Google lookup to search for an address. When a user selects an address from Google’s lookup, the street, city, state or province, zip or postal code, and country are populated.
- State and Country/Territory Picklists
- End users select state, province, country, and territory values from picklists when adding or editing addresses in custom address fields. Standard Address fields work in parallel with new custom address fields. If State and Country/Territory Picklists aren’t enabled in your org, the State and Country components of the standard Address fields remain free text fields. For more information, see AddressSettings in the Metadata API Developer Guide.
- Validation Rules
- For example, require that street, city, state, and ZIP code are all populated before you can save a field created with Custom Address Fields. For more information, see ValidationRule in the Metadata API Developer Guide.
- Apex classes and triggers
- For example, you create a custom address field, Office Address, on the Opportunity object, and you want the Office Address to always have a value. You then create an Apex trigger that is invoked when the Office Address field is unpopulated upon saving an Opportunity. The trigger populates the unpopulated Office Address field with the Billing Address on the parent Account before the Opportunity record is saved.
- List Views
- For example, you create a custom address field, Warehouse Address, on the Account object. Include the individual components of the Warehouse Address, such as the street or state, in an Accounts list view. For more information, see Create or Clone a List View in Lightning Experience in Salesforce Help.
- Reports
- For example, a report that sums the number of opportunities by the state or ZIP code within a custom address field. For more information, see Reports in Salesforce Help.
- Field History Tracking
- Track and display the history of a custom address field in the History related list of an object. For more information, see Track Field History for Custom Objects in the Salesforce Security Guide.
- Skinny Tables
- To avoid joins and improve the performance of certain read-only operations, include custom address fields in skinny tables, which contain frequently used fields. For more information, see Skinny Tables in Best Practices for Deployments with Large Data Volumes.
- Custom Indexes
- To speed up queries, you can create custom indexes for custom fields created with the Address type. For more information, see Indexes in Best Practices for Deployments with Large Data Volumes.
- Packages
- For example, include a custom address field in a managed package, or use a package to deploy that field to a sandbox. For more information, see Build and Release Your App in the Salesforce DX Developer Guide.
- Change sets
- Move objects with address fields created using Custom Address Fields from one Salesforce org to another. For more information, see Change Sets in Salesforce Help.
- Change Data Capture
- Receive real-time events for changes in custom address fields for new, updated, and undeleted records.
- Apex
- To create, edit, or delete records with custom address field data, use Apex.
- API
- To create a custom address field on an object, use Metadata API. To create, update, or delete a record with custom address data, use SOAP API or REST API. To retrieve information about custom address fields, such as the developer name, use Tooling API.