Skip to content
Normalize Account Billing Address
Apex
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
AccountTriggerEmpty.trigger
AcctTriggerHandler.cls
GoogleMapsCallout.cls
README.md

README.md

Overview and Business Case:

https://sf9to5.com/2018/05/28/normalize-account-billing-address/

Usage and Pre-reqs

AccountTriggerEmpty.Trigger

A logicless trigger for Account designed to call the Account Handler Class Only runs on After Insert and After Update

AcctTriggerHandler.cls

A class called by the Trigger that captures the old and new values of the Accounts that were part of the Trigger The values are checked to ensure that they are not blank and that the old and new values are different. The Accounts that meet the criteria are then passed to the GoogleMapsCallout class.

GoogleMapsCallout.cls

This class contains a method that calls out to the Google Maps API passing the Account Address. It then receives the results and parses the results to get the specific address field components. Once the components have been retrieved, either all or some of the address fields will be updated dependinig isStrictMode.

  • isStrictMode = True

    • will set all address fields to new values (overwrites all data) if result is ROOFTOP or APPROXIMATE
  • isStrictMode = False

Test Cases

  • Somewhere (street) GB (country)
  • unknown (street) Perth (city) WA (state) AU (country)
  • Perth (state) AUS (country)
  • A full local address in NY (all fields filled out but with abbreviations)
  • Just the state - NY
  • Just the country - US
  • Just the zip code 14534
  • The entire address written in the street field
  • Just a street name, once with a number and once with no number
  • Batch update
You can’t perform that action at this time.