Please Note
We have a new version of this package that uses record-triggered flow instead of process builder for the automations since Salesforce has announced they are deprecating process builder. We are leaving this page up so people who have this package version have the instructions if they need them. The link below will take you to the old package version 1.1. You can access the new package and instructions here.
Business Problem
Some sales teams assign territories based on county in the United States and this requires someone to update the county in Salesforce in order to assign the Lead or Account to the appropriate person. Automating the update to the County based on the Postal Code of an address will eliminate the need for someone to manually update this information.
We have built a free AppExchange solution that will automate this entire process for Leads, Contacts and Accounts. This App Exchange package will lookup the county based on the postal code of the following:
- Leads - the standard Zip Code field
- Accounts - the standard Billing Zip Code field
- Contacts - the standard Mailing Zip Code field
The package contains the following components
- Postal Code County Mapping (Custom Object) - this object holds the relationship between the County, State and Postal Code; each record is a single postal code.
- Postal Code County Mapping (Custom Tab)
- Postal Code County Mapping (Page Layout)
- City – (Custom Field on Postal Code County Mapping Object) - this is the city of the postal code record
- State – (Custom Field on Postal Code County Mapping Object) - this is the state of the postal code record
- Postal Code – (Custom Field on Postal Code County Mapping Object) - stores the postal code data for each record
- County – (Custom Field on Postal Code County Mapping Object) - this is the county of the postal code record
- County – (Custom Field on Lead Object)
- Billing County – (Custom Field on Account Object)
- Mailing County – (Custom Field on Contact Object)
- Lead | Update County from Postal Code (Process Builder)
- Account | Update County from Postal Code (Process Builder)
- Contact | Update County from Postal Code (Process Builder)
- Lead | Account | Contact – Update County from Postal code (Autolaunched Flow)
How to Configure the App
- Install the AppExchange package into a sandbox environment.
- Go to Setup | Flows and Activate the flow called Lead | Account | Contact – Update County from Postal code
- Go to Process Builder and Activate all three processes: Account | Update County from Postal Code, Contact | Update County from Postal Code and Lead | Update County from Postal Code
- Update field level security for the fields for the necessary profiles.
- Go to Leads | Page Layouts and add the County field to your Lead page layouts.
- Go to Accounts | Page Layouts and add the County field to your Account page layouts.
- Go to Contacts | Page Layouts and add the County field to your Account page layouts.
- Use Data Loader to import the records needed for the Postal Code County Mapping object in this file. We cannot guarantee this is the most up to date version of the data, there may be some discrepancies for some zip codes if updates are made. You are responsible for validating the data in the file.
- If you open the CSV file to review it, make sure to reapply the custom format to the postal code column, so the leading zeroes are added. We recommend using the Special format called Zip Code.
That's it, you are ready to test out the app!
Please Note
If you have other process builders in your org for these objects, you may just want to copy these processes into your existing ones. Salesforce recommends only having one active process per object.
How it Works
- The process Lead | Update County from Postal Code is triggered whenever you create a Lead with a value in the Zip Code field or if the value in the Zip Code field is changed. It invokes the flow called Lead | Account | Contact – Update County from Postal code. The process passes three variables into the flow:
- varObject = "Lead" - this tells the flow which path to choose since we are using the same flow for all three objects
- varObjectId = the Id of the Lead
- varPostalCode = the Zip Code of the Lead
The Account and Contact processes work exactly the same way. Looking forward to hearing any suggestions you may have and let us know if this helped you out!
How it Triggers an Update to Existing Records
Now you have the automation in place and it is working for all newly created or edited records, but what about the rest of your database? Here are the steps on how to easily trigger an update to all existing Lead records quickly:
- Go to Setup | Process Builder and select the process called Lead | Update County from Postal Code
- Click Clone to create a new version of the process.
- Change the Criteria for Executing Actions = No criteria just execute the actions! and click the Activate button.
- Go to Setup | Process Builder and select the process called Lead | Update County from Postal Code you cloned in Step #2. Click the version you installed from the package and Activate it. Delete the version you created in Step #2. Make sure the active version looks like this and has Criteria for Executing Actions = Formula Evaluates to true:
Any comments, questions, concerns – let us know in the comments! We would love to hear from you!
Cheryl, I have used or been educated by every How To’s currently on your website and they are phenomenal. My question is how hard it would be to replicate the process builders in the above App to flows to help try and future proof with the migration from PB’s to flows. I’ve got a use case for the County update and wanted to check before I started digging into it. Thanks for all of the education!
Hi Spencer,
Thank you for this feedback, this makes our year and is the whole reason we work on sharing these with the community!!! We are currently working on upgrading all of the packages in the How To’s section to use only flows. We will ping you when this specific package has been upgraded. Thanks again!
Hi Spencer,
We have complete upgrading the package to use flow instead of process builder. You can find the new article here: https://bluninjas.com/how-tos/update-county-based-on-postal-code-flow/