Working with geocodes location in salesforce



Are your sales and marketing teams facing problems in locating the address of your customers?
     If your answer is yes then you are in the right place.

Are your sales and marketing tasks distribution optimized based on geolocation?
     If your answer is no then you are in the right place. 


Let's get started with the geolocation concept in salesforce.

As default salesforce is providing geolocation field to below objects(This will be released in summer 16 release):


  • Billing Address on accounts
  • Shipping Address on accounts
  • Mailing Address on contacts
  • Address on leads
Whenever a record is created in the above objects with some address these geolocation fields will auto-populate from data.com and the best part is, this does not require a data.com license. Each field above has three subfields(latitude, longitude, and accuracy) to store geolocation data. These fields are not present on page layout but you can display them using formula fields and you can query them as well.

You can also create custom geolocation fields on objects.




Now most of us must be having a question like we can use a text field also to store the latitude and longitude, Then why we should use the geolocation field.

I also had that question when I came to know about the geolocation field.

 The benefit of using the geolocation field is you can utilize this field directly in the query where clause for comparing the distance or you can populate the distance in the formula field using distance function without any calculation.

Sample Query using geolocation field:
SELECT Name, Location__c FROM Customer__c WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 30 

This query will return the records in the 30 mi range of the lat/long hardcoded in the query.
You can also use the distance function in order by clause to order the records depending on the distance.

One of  the best business scenario to explain the use and benefit of geolocation field:

Suppose your salesperson is in the field for the market visit. He needs to figure out the nearest customer whom he can visit.
 So the developer can use the above query by replacing the hardcoded lat/long to the current lat/long of the salesperson to tell him the nearest customer.
Salesperson can also use this functionality to schedule his complete day in the optimized manner.

This can be very cost-effective for organizations using salesforce and this functionality.


That is all for this post.

HAPPY LEARNING.....!!!

Comments

Popular posts from this blog

Dynamic Forms in Lightning Record Pages

How does Gen AI work?

Getting started Salesforce Lightning!