Skip to content

Populate a State Value From a US ZIP Code Using a Salesforce Flow

Reducing manual data entry results in better user adoption, less friction for prospects, and an overall better user experience. This guide creates a Salesforce flow that fetches the state value from an entered US ZIP code and populates the address's state field, removing the need for users to enter a state value at the point of record entry.

The ZIP code data is part of AddressTools.

Create a Flow to Automate State Population

The following example verifies the billing address block on Accounts. Adapt it to any object and address block configured with AddressTools.

  1. Go to Setup > Flows.
  2. Select New Flow.
  3. Choose Record-Triggered Flow.
  4. Select the object being configured for.
  5. Set Trigger the Flow When to A record is created or updated.
  6. Click Done.

Set the entry conditions:

  1. Condition Requirements: All Conditions Are Met (AND).
  2. Add conditions:
  3. pw_ccpro__BillingCountryLookup__c Equals United States
  4. BillingState Is Null TRUE
  5. BillingPostalCode Is Null FALSE
  6. When to Run the Flow for Updated Records: Every time a record is updated and meets the condition requirements.
  7. Optimize the Flow For: Fast Field Updates.

Add a Get Records element under the Start element:

  1. Label: Get ZIP.
  2. Object: ZIP Code.
  3. Condition Requirements: All Conditions Are Met (AND).
  4. Condition: Name Equals {!$Record.BillingPostalCode}.
  5. How Many Records to Store: Only the first record.
  6. How to Store Record Data: Automatically store all fields.

Add an Update Records element under the Get Records element:

  1. Label: Update Account.
  2. How to Find Records to Update and Set Their Values: Use the account record that triggered the flow.
  3. Set Filter Conditions: None-Always Update Record.
  4. Set field values: BillingState = {!Get_ZIP.pw_ccpro__State__r.Name}.

Connect the elements and activate the flow.

Running This for Historic Data

To run this logic against existing records in Salesforce, see How to Fire a Trigger for Existing Records in Salesforce Using Flows.