function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
uma52551.3972270309784705E12uma52551.3972270309784705E12 

Populate County field on the Lead object from the zip code

Hi All,

I am havinf a custom object that contains zipcodes and I have created a county name custom field in the Lead Object now I want to write a trigger to update the county name field of the lead object by looking into the zipcodes in my custom object. Please help me how to wrtie trigger and test class for this...

Thanks in advance..
Best Answer chosen by uma52551.3972270309784705E12
uma52551.3972270309784705E12uma52551.3972270309784705E12
Solved by writing a trigger...

All Answers

Sonam_SFDCSonam_SFDC
If I understand this correctly you have an object with zip codes and you have another object with country field and you wsh to populate this field with correct contry code looking at the zip code.

So, user will be entering the zip code in the lead Object from where you will choose the correct country code and populate on the Lead object..right?

Could you please elaborate on the flow..a bit confusing.
uma52551.3972270309784705E12uma52551.3972270309784705E12
Solved by writing a trigger...
This was selected as the best answer
Cheryl Fernandes BNCheryl Fernandes BN
For those of us who do not know how to code, here is a solution you can easily configure using process builder and flow. 

We have built a free app that updates the County based on the value of the zip code on the Lead (it also includes a solution for Accounts and Contacts). Here is a link to the blog article that describes the steps on how to configure the app and also contains a link to the package to install in your sandbox: https://bluninjas.com/update-county-based-on-postal-code/