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
Neel88Neel88 

Help with nested from 2 different objects

I am trying to find all leads within a certain radius of another lead say LEAD_A. The latitude, longitude of the postalcode/zip of LEAD_A is to be extracted from an object called zip_code__c (object) unrelated to Leads
with FIELDS
location__c (type GEOLOCATION) has lat,long
zipcode__c (text field)
city__c, State__c

I can get that with soql similar to
*select name, company, postalcode from LEAD where postalcode in('zip1','zip2')*

to get to that I am building a query as below

select name, company, postalcode from lead where postalcode in (select zipcode from zip_code__c where DISTANCE(location__c, GEOLOCATION(LEAD-A.latitude, LEAD-A.longitude)) < 20 )

Please help with this interesting challenge

I want to display this on the Lead layout via a VF page or button !