• Stronger Customer Relationships
  • +1-949-878-7411
  • ramana@varasi.com
    Varasi logoVarasi logoVarasi logoVarasi logo
    • Home
    • Offers
      • Salesforce for Growth Business
      • Salesforce for Subscription Business
      • Salesforce Reset
      • Salesforce CPQ Implementations
      • Salesforce for Nonprofits
      • Cloud Solutions
    • Insights
      • The Varasi Way
      • Salesforce
        • Salesforce For Executives
        • Salesforce For Architects
        • Salesforce For Developers
      • Leadership Talk
      • CRM Best Practices
      • Sales Management
    • How We Work
    • About Us
    • Careers
    • Contact
    0

    Using Geocode Rules for Account Allocation in Salesforce

    One of the parameters you may use for territory planning is proximity of your account managers to their accounts. Having account managers close to their accounts allows you the luxury of high touch service to your customers while limiting the travel costs associated with it. The proximity helps the account managers build a more personal and stronger relationship with the customer. 

    A few considerations you may have while doing territory planning and account allocations:

    • Which are the accounts within a 20 mile radius of my account manager?
    • If an account manager is managing one account, which other accounts are close to that account?
    • You may also seek to know which accounts are within a 50 mile radius while planning some account based marketing or a customer event. 

     

    In this article we explain how to use Geocodes to calculate distance between accounts and identify the nearest account. You can extend it to find accounts within a certain radius and other use cases.

    Setting up distance calculation

    Calculating distance using the Account address requires some steps:

    1. Activate the data integration rules

    Go to setup > “Data Integration Rules”.

    These are rules that update address longitudes and latitudes using geocode service. You will need to activate data integration rules for shipping/billing address of accounts.The rule names are “Geocodes for Account Billing Address” and “Geocodes for Account Shipping Address”. Here is more information on activating a data integration service for a data service. 

    1. Update of longitude and latitude fields

    Once the rules are activated, the service updates the longitude and latitude fields on the Account record with appropriate values once the address fields are updated. The external service updates the record asynchronously. This means, when you insert or update an account address, the longitude/latitude fields on the Account object in that transaction are either null or old values before update. The new longitude/latitude values get updated in a separate transaction asynchronously. By default, your trigger will not see the updated fields and the shortest distance calculation will not work. 

    To make it work, you have to take care of a few things mentioned below:

    1. In the data integration rules setup, uncheck the box “Bypass triggers”. This means that when the Geocode service updates account longitude/latitude with new values, it will trigger the Account update trigger.
    2. Write logic in your trigger to check if longitude/latitude has changed and re-calculate distances if it does. If those are changed, that means distance needs to be recalculated. Thus your trigger is called twice.
    • First, when the account is inserted/updated. This time the longitude and latitude values are either null or old values. 
    • The trigger is called once again when the Geocodes service updates longitude/latitudes. This time you recalculate distances as per your requirement.

    Geocodes allow you to use address information to codify any distance based logic in your system. Geocode rules are available for Account billing/shipping address, Contact mailing address and Lead address. For more information, you can refer to this article.

    Team Varasi

    Share on Facebook Share
    Share on TwitterTweet
    Share on LinkedIn Share
    Share on Pinterest Share
    Send email Mail
    Shailesh Bhide
    Shailesh Bhide
    Shailesh is a Principal at Varasi. He shares thoughts and insights on technical know-how and patterns that helps us build elegant Salesforce solutions for our customers. He is passionate about leveraging the Salesforce platform to its full potential.

    Related posts

    April 15, 2024

    Salesforce CI Using Azure DevOps


    Read more
    Quoting in Salesforce
    February 22, 2024

    Do You Need Salesforce CPQ For Quoting?


    Read more
    asynchronous processing
    January 31, 2024

    Asynchronous Processing in Apex On Salesforce: Part 2 – Queueable Apex


    Read more

    23591 El Toro Road
    Suite 172, Lake Forest, CA 92630

    Tel: +1-949-878-7411
    Email: ramana@varasi.com

    Quick links

    • Salesforce for Growth Business
    • Salesforce CPQ Implementations
    • Salesforce for Subscription Business
    • Salesforce for Nonprofits

    Quick Links

    • About Us
    • How We Work
    • Insights
    • Careers
    • Privacy Policy

    Connect with Us

    © 2017 Varasi. All rights reserved.

          We would love to hear from you.