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.
- Go to Setup > Flows.
- Select New Flow.
- Choose Record-Triggered Flow.
- Select the object being configured for.
- Set Trigger the Flow When to A record is created or updated.
- Click Done.
Set the entry conditions:
- Condition Requirements: All Conditions Are Met (AND).
- Add conditions:
pw_ccpro__BillingCountryLookup__cEqualsUnited StatesBillingStateIs NullTRUEBillingPostalCodeIs NullFALSE- When to Run the Flow for Updated Records: Every time a record is updated and meets the condition requirements.
- Optimize the Flow For: Fast Field Updates.
Add a Get Records element under the Start element:
- Label:
Get ZIP. - Object:
ZIP Code. - Condition Requirements: All Conditions Are Met (AND).
- Condition:
NameEquals{!$Record.BillingPostalCode}. - How Many Records to Store: Only the first record.
- How to Store Record Data: Automatically store all fields.
Add an Update Records element under the Get Records element:
- Label:
Update Account. - How to Find Records to Update and Set Their Values: Use the account record that triggered the flow.
- Set Filter Conditions: None-Always Update Record.
- 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.