Syntax Highlighter JS

Friday, May 3, 2013

New Managed Package for Geocoding

I have released an new managed package of the Geocoding engine.

This version has an application where you can see logs from past attempts as well as change some settings.

Due to the fact that Google enforces geocoding limits by IP address and those addresses are shared on the Salesforce platform, I have added support for Map Quest and Bing geocoding services.

These services will require you sign-up for a free or paid API Key that comes with its own limits, but those are based on the key and not the IP address.

On the settings screen, I have included a link to the sign-up page for each service.

05/06/13 Update #2 : The issues with accessing the custom settings and scheduling problems have been fixed and the updated managed package can be found here.  Please install the new version (1.7) over any older editions.


  1. Craig,

    I am sorry but I don't have plans to release the source code to this project at this time. It is meant to be a free tool for administrators and not a teaching example for developers.

    I am however open to suggestions about future enhancements.


  2. Hi Anthony, thanks for the tool and making it available. I installed in in our sandbox that has about 80k account records. The first couple of days it appears it was processing a decent volume. However, now it appears to just be updating a couple of accounts a day. I have both Mapquest and Bing keys configured. Any idea what may be going on?



  3. Fahd,

    Please make sure that you are on the newest version (1.72), which can be found in the original link / listing above. This version fixes a JSON parsing issue with the Bing Engine, has better logging, and will now skip accounts that have errors (such as a custom validation error) during an update attempt.

    At this time, those records are permanently skipped. However, I plan to change that in a future version.

    As of now the engine will attempt to use Google, then Bing (if an API key is found) and then MapQuest (if an API key is found) to geocode the account. So you may see up to 9 attempts (3 for billing, 3 for shipping in the log section of the application.

    Once you have updated to the newest version, please reply back with what errors show in the log tab of the geocoding application. Once I know more about the log, I can probably help figure out what is going on.


  4. Hi Anthony, i installed the package however seems to be playing up?

    1. There is an error when i run all tests on the classes
    DC_GG.PostInstallClass testInstallScript Fail
    System.AsyncException: The Apex job named "DC:GeoCodeUpdater" is already scheduled for execution.
    - This however does not prevent me from updating any code i've created.
    2. There are successful logs with status = OK. However if i go to the address. i cannot see any of the co-ordinates being written to the account? I've extracted the account table and cannot find the field anywhere.
    thanks for making the package available.

  5. Jimmy,

    If the job named DC:GeoCodeUpdater shows under Setup->Administration Setup-> Monitoring -> Scheduled Jobs, then you should be good to go. In that case the error probably has to do with a 2nd attempt at an install or upgrade. Either way if data is being populated in the custom field, you should be good to go.

    The data is stored in a custom field with the data type geolocation. The field is named DC_GG__BillingGeoCodeData__c. However the long / lat subfields are used to access the data by SOQL and those fields are: DC_GG__BillingGeoCodeData__Latitude__s and DC_GG__BillingGeoCodeData__Longitude__s.

    I am working on getting a version of this into the app exchange but that might take some time.


  6. Hi Anthony, thank you for the great tool!
    I have the same problem as Fahd Alfadli. We have about 26k accounts. And at the first couple of days it was processing about 3k. However, now it stop. No new records in log. DC_GG__SkipRecord__c containt 127 records.
    I am on the newest version (1.72).
    Job named DC:GeoCodeUpdater shows under Setup->Administration Setup-> Monitoring -> Scheduled Jobs
    I have both Mapquest and Bing keys configured.
    I set Max Accounts Batch Size to 20
    What this setting means? Whta is the best number for my setup?
    Please help me to start processing again.

    Thank you!


  7. Vladimir,

    When either DC_GG__BillingNeedsGeocodeUpdated__c or DC_GG__ShippingNeedsGeocodeUpdated__c = true, the account will be put in the batch to be processed. These are formula fields that look at the last updated time stamp vs the last geocoded time stamp.

    Do your 26k accounts have billing and/or street addresses? Only records with enough data (i.e. at least a zip or city/state) to get a valid geocode result will even be processed.

    The skip records are accounts where an update failed for some reason - i.e. a custom validation rule failed. In the current version, those are permanently skipped. When I get time, I plan to update the logic such that these records will automatically attempt to re-process at some time in the future.

    The batch size is the number of accounts that will be processed at the scheduled time (i.e. each hour). This is defaulted to 10 but could be set as high as 99. However each service (i.e. bing, google, etc) has daily limits. I offer this option so you can turn it up or down depending on how it behaves.


    1. Hi Anthony, thanks for the reply.
      I just watched at the BillingLastGeocoded records, the last dates a refers to 9/17/2013.
      The script stopped working for some reason. Possible conflicts with some settings in Salesforce. I'll try to find out.

      Thank you!

    2. Vladimir,

      Do you have any accounts where the ShippingNeedsGeocodeUpdate field OR the BillingNeedsGeocodeUpdated field is True? If the answer is no, then the system is out of accounts to process. If the answer is yes then you might have hit a new problem that I need to look into.


    3. Hi Anthony,

      Yes, the ShippingNeedsGeocodeUpdate fields and the BillingNeedsGeocodeUpdated fields has the True values.

  8. It appears to interfere with the CRMfusion Inc.'s DupeBlocker package. I know get an error email at the same time that your job runs:

    DupeBlocker has encountered an error. Please contact your Salesforce administrator with the following information:

    *** Trigger: Account after update
    *** isMerge value: false
    *** size: 1
    *** Trigger.old size: 1
    *** Exception Type: System.QueryException
    *** Exception Cause: null
    *** Exception Message: sObject type 'Account' is not supported.

    1. Brian, I will be posting a copy of the code to GIT Hub shortly. If you get a chance to resolve the error, I would appreciate knowing the solution so that I can update my code.

  9. Craig, I have decided to post the code. Check back on the main page of the site later today for a new post with a link to the code.

  10. Hi Anthony

    I downloaded the new package and I can see the apex jobs for Geocorder itis showing the same number of accounts which are there in the dev sand box which means it is picking up all accounts for processing and even checked the fields DC_GG__BillingNeedsGeocodeUpdated__c or DC_GG__ShippingNeedsGeocodeUpdated__c are set to true but some how it is not getting the lon and lat values in BillingGeoCodeData fields. Is there is something I am missing and not need to upadte to make this work. Please let me know.
    Thanks in advance

    1. Gaurav,

      Since Salesforce has released the newest version, please see the updated version here:


  11. Gaurav,

    Sorry for the late reply but I just recently saw your post. Please make sure that the log entries contain valid responses (i.e. OK), that the job shows under scheduled jobs, and that you don't have the max log entries setting set to larger than 2000.

    I am working on a new release that will fix bugs like these. It will also include a map tab which will let you view the data on a google maps page like I have given as an example. Keep an eye on the main blog page for that release - it should come out not long after the next quarterly release update by Salesforce goes into production.