Update County Based on Postal Code Using Process Builder
[ARCHIVED - See New Article Using Flow]

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

  1. Install the AppExchange package into a sandbox environment.
  2. Go to SetupFlows and Activate the flow called Lead | Account | Contact - Update County from Postal code
  3. 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
  4. Update field level security for the fields for the necessary profiles.
  5. Go to Leads Page Layouts and add the County field to your Lead page layouts.
  6. Go to Accounts Page Layouts and add the County field to your Account page layouts.
  7. Go to Contacts Page Layouts and add the County field to your Account page layouts.
  8. 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

  • Here is what the flow looks like:

  • Test it out by updating the zip code to have a value and confirm the County is populating. Then remove the zip code and make sure the value is removed from the County field.

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:

  1. Go to Setup | Process Builder and select the process called Lead | Update County from Postal Code
  2. Click Clone to create a new version of the process.
  3. Change the Criteria for Executing Actions = No criteria just execute the actions! and click the Activate button.

  1. Using Data Loader, run an export for all Leads that are in the United States and contain a value in the Zip Code field. Make sure to include the Lead Id in your export.

  1. Click Update in Data Loader for the Lead object and insert the export file you exported in step #4. Make sure to only map the Lead Id.

  1. 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:

For any questions, comments, concerns – let us know in the comment section below!
We would love to hear from you!

Share This Story, Choose Your Platform!

About the Author

Cheryl Fernandes

Cheryl is a certified Salesforce Application Architect and is the Founder and Lead Salesforce Consultant at Blu Ninjas. She has been working with Salesforce for 12 years and has helped companies in financial services, insurance and beauty industries implement solutions on the platform. Flow is her favorite Salesforce declarative tool, it is a game changer for anyone who does not know how to code.

4 thoughts on “Update County Based on Postal Code Using Process Builder – ARCHIVED – See New Article Using Flow”

  1. 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!

    1. 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!

  2. I installed this in order to get the county from zip. Installed ok, and I created a text field called County on the account record.
    I edited the zip to try and force a change, but nothing happens. I can’t get it to work. I’m not looking to upload zips as we have them.
    I just wanted to use data loader to remove and then add back in the zips on accounts to get County to populate, but if it won’t work on one record with manual edit, I’m not sure it will work. Am I doing something wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top