Zip Code Populate city and state?
I am wondering if anyone has create, or know of a way to create this formula.
I am trying to create a formula that when a zip code is added to my zip code field, it will automatically fetch the city name and state name, and paste the data into my two separate city and state fields?
7 replies
-
Where are you going to get the zip code information?
-
If you had a table with Zip Codes, you could use something like this in "Trigger after update".
let myCustomer := this;
City := text((select ZipCodes)[ZipCode = myCustomer.ZCode].City);
State := text((select ZipCodes)[ZipCode = myCustomer.ZCode].State)
-
-
Nice!
-
-
Can't use http() in a trigger, so it would have to be a button or something. You would need an API key.
Use this API to find out the city, state, latitude, longitude, and time zone information for a zip code. The JSON and XML responses will allow contain alternative acceptable city names for a location. Send a GET request to https://www.zipcodeapi.com/rest/<api_key>/info.<format>/<zip_code>/<units>.
let URL := "https://www.zipcodeapi.com/rest/" + API_KEY + "/info.json/" + Zip + "/degrees";
let response := http("GET", URL);
City := response.result.city;
State := response.result.state
-
slowwaggon's solution is better for auto updates.
I grabbed a zipcode DB from here.
https://simplemaps.com/data/us-zips
I imported the csv and created a new table. I took the defaults except for zip I changed from a Number to Text so it would keep leading zeros.
let myCustomer := this;
City := text((select uszipsv1)[zip = myCustomer.Zip].city);
State := text((select uszipsv1)[zip = myCustomer.Zip].state_name)
Content aside
- 5 yrs agoLast active
- 7Replies
- 3359Views