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
Raj ChakrabortyRaj Chakraborty 

how to write controller that will find lead within 50 mile of the postal code

karthikeyan perumalkarthikeyan perumal
Hello, 

Step 1: 
       Update you Lead address with Latitude,Longitude field not showed in page layout. if you dont know the lat and long do the below steps.
       You have to wirte a batch apex to update your lat and long based on your lead address. connect googleAPI to find out Lat and long for postal        code and address which you paased as JSON parameter for googleAPI it will return lat and lang.
       
       after upadted lead information make sure you dont ave any null values for lat and lang using this query. 

       "SELECT count(id) FROM Lead WHERE Latitude != null AND Longitude != null"

         then use your apex to to find lead within 50 miles using that main postal code lat and long. 


hope this will give some idea to gohead with your code process.

Thanks
karthik