Leverage Zip Code To Improve User Experience In Salesforce
It’s a fact, most marketing and sales organizations have to collect customer data and want to do so in a timely manner. Moreover, the more data they have to collect, the more chances there are for errors, not to mention increasing the customer's time to fill in the in-take form. What if there was a way to use one data point that would auto-populate multiple fields? Well, there is a way!
The following 11 steps walk you through how to set up ZipCodeAPI.com to connect with your org. DISCLAIMER: ZipCodeAPI.com is a third-party service; we are not recommending this service but simply showing the workaround for this particular problem.
This solution will show how to get the time zone (including daylight saving information) along with city, state, and country information bussing an open-source API and updating the Account record with the response from the API call.
In this example, we will be using the API from https://www.zipcodeapi.com/.
Navigate to https://www.zipcodeapi.com/API and click on “Free key”.
Provide an Application Name (could be any name) and enter your email address (must be valid).
Once all the details have been entered, please click on “Register Application”.
Check your inbox, you will receive an email with a link to activate the API key. Open the link and click on “Verify”.
After verification, you will see the API Key, store this API key since we will need it to use it in our callout from Salesforce.
Now we need to white list the API hostname to allow Salesforce to get access to it. Login to your Salesforce org and go to Setup→ Remote Site Settings → click New. Enter “https://www.zipcodeapi.com/” and then click Save.
Go to the Account object and add a new custom field called “Customer Time zone” with the data type set as Text.
In our example, we will be referring to theBillingPostalCode field. So when the value of that field is updated, we will update the “Customer Time zone” field based on the new postal code.
Create a Trigger on the Account object. Sample code is available here.
Create a service Apex class where the logic will be stored. Sample code can be found here. After creating this class, please replace the variable “apikey” at Line 22 with the key which you created on Step 5.
Once the above steps are completed, test your code by updating the Billing Postal Code with a proper zip code. You will see that the State, City, Country, and Customer Time zone fields are updated near real-time.
The full code is available here in the GitHub repository:https://github.com/skalavala-sudo/TimezoneFromPostalCod
Now that the zip code takes care of multiple data points, your users can breathe a sigh of relief as the customer’s zip code does all the work for them. In addition, your customers/prospects will not have to input as much data, which we know they will appreciate. Last but certainly not least, your customers will benefit from a shorter wait time and your users will have the ability to contact them during regular business hours improving the chance of the calls being answered.
Keep these points in mind before trying this solution:
● You have to register with zipcodeapi.com before using this solution.
● How many API callouts does your org need? Plans are free for 10 requests per hour but above that, there is a yearly fee (dependent upon the plan).
If your users would like to input less data while having more fields auto-populated, then this solution is right for you. With just a zip code, this highly effective solution can capture important data early in the discovery process that can be used later. By following the above steps, help your users to collect customer data more efficiently so you can have a more efficient org.
If you are interested in learning more about how we can address your complex business needs through our innovation and thought leadership, please reach out to email@example.com or visit our website www.cloudperitus.com.