Geocoding Salesforce Records Natively

nialljpmurphy
Jul 20, 2017 · 3 min read

Why would you want to geocode accounts?

Geocoding has many benefits. Salesforce supports geocoded fields and also search of those fields enabling you to perform searches like show me all accounts within 5 km of this location etc. This can be quite powerful for a number of applications. I’m working on a project where I wanted to map (partner) account locations on a map and publish that map to a public (communities) website. So I did some renewed digging into this feature.

Standard Geocode Fields

Custom Geolocation Fields

Historically one would have used third party services such as the google maps api to populate these fields : https://developers.google.com/maps/documentation/geocoding/intro

However this isn’t ideal, you need to manage keys and be aware of usage limits that may impact your application.

In the Summer’16 release Salesforce made a data.com feature to geocode these fields generally available. How do we set that up ?

Automatically Geocode Your Records

First you will want to go to Data Integration Rules in Setup

Activate the rule(s) you want to update for example in my case I want to ensure that the billing account geolocation data (BillingLatitude, BillingLongtitude) is populated.

Side Note :

Account BillingAddress, ShippingAddress etc are compound fields so while the location information will be accessible through the API and in any search queries or Apex you want to run its not easily visible in the standard UI so particularly for testing purposes you might want to create custom formula fields that expose these parts of the compound address field.

Also you need to create custom formula fields to expose the BillingLatitude and BillingLongtitude information on the Account Layout.

See H&T article linked below for further details. The steps are as follows for the custom formula field:

  • Data Type: “Formula”
  • Formula Return Data Type: “Number” (with 4 decimal places)

Enter the formula.

  • Use the Advanced Formula tab
  • Click “Insert Field,” and enter the “Latitude” field

Add the field to your page layouts.

Create custom formula fields for latitude and longtitude to expose BillingLatitude and BillingLongtitude

You can also add the Data Integration Rules related list to the object page to check the status of these Data Integration Jobs

Adding Geocode Fields To The Account Layout

https://help.salesforce.com/articleView?id=000231046&type=1

)

nialljpmurphy

Written by

Business Architect at Salesforce. Building Solutions that help organisations connect with each other and their customers. Collaboration, Commerce, Portals etc.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade