|The raw data looks like this|
|To and from the gym tonight|
Geolocation fields are currently beta and available for all editions of Salesforce. Check out the notes within the Salesforce documentation as this beta field type is laced with various limitations like:
Other limitations of this geolocation beta release include:
- Geolocation fields are not supported in custom settings.
- Geolocation fields are not available in dashboards, Visual Workflow, or workflow and approvals.
- Geolocation fields cannot be searched.
- Geolocation fields are not available in Schema Builder.
- DISTANCE and GEOLOCATION formula functions are available only when creating formula fields and in Visual Workflow.
- Geolocation is supported in Apex only through SOQL queries, and only at the component level.
Also, note that Geolocation field counts as three separate fields
- A mysterious internally designated field
When creating a new field, "Geolocation" is one of the recently added field types. You may have noticed it, but if you didn't, you'll find it in the options between the "Email" and "Number" types:
On Step 2 of the new field creation wizard, you'll specify the coordinate display notation, being in either "Degrees, Minutes, and Seconds," or "Decimal" notation. You'll also need to specify the precision by way of decimal places. Looking at my test data above, I've recorded 5 decimal places and will specify this below.
Once you have your new field added to our object and assigned to a page layout, this is what your new Geolocation field(s) will look like. Remember the note about each Geolocation field counting as three? Here you will see the two that are visible to the user.
What about the 3rd field that was designated for internal use? Here's what it looks like within the Force.com IDE Schema:
If you attempt to use it in a standard select SOQL query, you'll find that you're out of luck... but wait there's a catch!
Per Salesforce, Winter '13 brought along two formula functions that can be used within SOQL queries; Distance to determine the distance between two locations and Geolocation which is a pairing of a latitude and longitude. An example usage of these would be a query that brings back records based on proximity to a set of coordinates.
- The use of "Geolocation" will allow us to specify a latitude and longitude
- The use of "Distance" will allow us to indicate a Geolocation field (you guessed it, that mysterious 3rd field), a new Geolocation to compare against, and whether we want to compare in miles ("mi") or kilometers ("km").
I hope you've enjoyed this post and as always, feel free to leave comments. We'd love to hear how you're using Geolocation fields in your business environment.