Geolocate your customers close to you

Sous-titre

Aurélien Laval

- Titre : Geolocate your customers close to you

- Auteur : Aurélien Laval

- Parution : 8 août 2016

- Public visé :

- Licence : Les sources présentées sur cette page sont libres de droits et vous pouvez les utiliser à votre convenance. Par contre, la page de présentation constitue une œuvre intellectuelle protégée par les droits d'auteur. Copyright ® 2016 Aurélien Laval. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents, images, etc. sans l'autorisation expresse de l'auteur. Sinon vous encourez selon la loi jusqu'à trois ans de prison et jusqu'à 300 000 € de dommages et intérêts.

Sommaire

- I. Introduction

- II. Requirements

- III. It is now easy to geolocate your customers close to you

- III-A. SOQL query

- III-B. Custom field

- IV. Summary

- V. Useful resources

I - Introduction

Salesforce just announced during the Summer ‘16 release that is now possible to geolocate your customers close to you.

For example, you can geocode and know the distance between two points in the aim to see your customers which are less than 50 miles from you.

This is the perfect tool for your sales and marketing team to find prospects.

How it works? To enable this feature, you will have to use SOQL queries but all of this is a cinch with Automatic Geocodes for Address.

II - Requirements

To test this feature, you will need a developer environment.

If you don't have one of these yet, click on this link right now to sign up and join the adventure, it's free !

III - It is now easy to geolocate your customers close to you

There are two ways to use this new feature : a SOQL query or a custom field.

III-A - SOQL query

You can geolocate your customers thank to a SOQL query by using the method DISTANCE() and GEOLOCATION().

This is a query's example :

1. SELECT Name, shippingCity, shippingState, shippingCountry, shippingLatitude, shippingLongitude

2. FROM Account

3. WHERE DISTANCE(shippingAddress, GEOLOCATION(37.79340, -122.39420), 'mi') < 50

III-B - Custom field

Moreover, you can create a custom field to use it in your reports and see customers who are close to you.

The custom field has to be a formula which return an integer and looks like that :

1. DISTANCE(BillingAddress, GEOLOCATION($Organization.Latitude, $Organization.Longitude), 'mi')

The parameter ‘mi' means ‘miles' but you can use ‘km' to calculate with kilometers.

IV - Summary

In this article, you have learnt how to geolocate quickly and easily your customers according two ways : a SOQL query or a custom field.

This is a great news for your sales and marketing team.

So, don't waste your time, test it and develop an application !

V - Useful resources

- Making Your Salesforce Data Location-Aware ;

- Salesforce Summer '16 Release Notes ;

- Force.com SOQL and SOSL Reference.