Salesforce has recently released a new field data type called Geolocation (still in beta). Many customers from within the logistics industry and venue providers find it helpful in terms of:
- it helps to calculate the distance between locations in supported units
- the correct format of the coordinates can be stored
- identify the traveling time from one place to another
Some information that can help developers understand this new data type are:
- this feature is available to all editions
- Geolocation data type consist of 3 custom fields which is accountable to your organisation’s limit. These three accounted fields are – latitude, longitude, and another for internal use.
- in SOQL, the given sample query can be performed. Please note that the component fields (longitude and latitude) can only be queried.
- Select Id, Name FROM Account WHERE Headquarter_Geolocation__Latitude__s = -37.8021710 AND Headquarter_Geolocation__Longitude__s = 144.9540820
- formula functions availability for Geolocation and Distance can only be used together with a formula data type
- For more details on the other possibilities and limitations, please refer to:
The following screen shots show how the feature can be utilised. The main objective of the geolocation usage for the following illustration is for the Salesperson to know the distance between the Headquarter office and the Branch office. We have included the steps on achieving the objective.
1. Create a ‘Geolocation’ custom field for the Headquarter office
2. Create a ‘Geolocation’ custom field for the Branch office
3. Create a formula field as such utilising the Distance function: DISTANCE(Headquarter_Geolocation__c,Branch_Geolocation__c, “km”)
4. Assign the field to the layout accordingly
5. Get the coordinates of the locations (we use Google map in this example)
6. Populate the custom fields for the Headquarter/Branch office with coordinates from #5
Upon saving the coordinates, the user should be able to see the automated calculation of the distance between the two locations!