Newer Version Available

This content describes an older version of this product. View Latest

Compound Field Considerations and Limitations

Address and geolocation compound fields are convenient, and result in more concise, clear code. However, there are a number of things you should consider when using them in your apps.
Both address and geolocation compound fields have the following limitations.
  • Compound fields are read-only. Use the individual field components to update field values.
  • Compound fields are accessible only through the SOAP and REST APIs. The compound versions of fields aren’t accessible anywhere in the Salesforce user interface.
  • Compound fields can’t be used in Apex, because there is no Apex data type for compound fields. Use the individual field components to access or update field values.
  • Compound fields can’t be used in Visualforce, for example, in an <apex:outputField>. Use the individual field components to access or update field values.
  • Compound fields aren’t searchable. For proximity searches, use a WHERE DISTANCE(field, GEOLOCATION(lat, long), "units") < desiredPoximity clause. For text string matches—for example, matching a city or postal code—search the individual fields.
  • Compound fields can’t be imported or exported. Use the individual field components to load or export values.
Address compound fields have the following limitations.
  • Compound address fields are only available for standard addresses, that is, those address fields that exist as a basic part of the standard objects included in Salesforce. You can’t create custom compound address fields.
  • The geolocation component of address fields isn’t set automatically. You need to use a geocoding service to set these values before you can use address fields as locatable values. Search the AppExchange for “geocode” to find a number of possible solutions.
  • Address fields are only supported by DISTANCE() in SOQL. DISTANCE() calculation for address fields isn’t supported in formula fields, Apex, or any other calculations. (DISTANCE() calculation in formula fields is supported for geolocation fields.)
  • Address compound fields can’t take advantage of custom indexing on the geolocation element of the field. If you have more than 250,000 records, be aware of the performance implications of performing WHERE DISTANCE() and ORDER BY DISTANCE() operations on address fields. You can work around this limitation by adding an extra custom geolocation field, and indexing on that field instead.