You need to sign in to do that
Don't have an account?
Harpreet Kaur 45
Getting Error when deploying to production, Address field does not exist on lead. I am using Address in Distance() in SOQL in apex class
global with sharing class LeadsNearbyMe {
public static List<Lead> result;
@RemoteAction
global static List<Lead> getNearby(String lat, String lon) {
Location loc1 = Location.newInstance(Decimal.Valueof(lat),Decimal.Valueof(lon));
result=[SELECT Id, Name, Longitude, Latitude, Street, City,State,Country, PostalCode FROM Lead WHERE DISTANCE(Address,:loc1, 'km') < 60 ORDER BY DISTANCE(Address, :loc1, 'km') LIMIT 10];
return result;
}
}
public static List<Lead> result;
@RemoteAction
global static List<Lead> getNearby(String lat, String lon) {
Location loc1 = Location.newInstance(Decimal.Valueof(lat),Decimal.Valueof(lon));
result=[SELECT Id, Name, Longitude, Latitude, Street, City,State,Country, PostalCode FROM Lead WHERE DISTANCE(Address,:loc1, 'km') < 60 ORDER BY DISTANCE(Address, :loc1, 'km') LIMIT 10];
return result;
}
}
<complexType name="Lead">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="AcceptedEventRelations" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Account_Number__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="ActivityHistories" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Address" nillable="true" minOccurs="0" type="tns:address"/>
<element name="Administrator_Email__c" nillable="true" minOccurs="0" type="xsd:string"/>
line 12, column 13: 'km') < 60 ORDER BY DISTANCE(Address, :loc1, 'km') LIMIT 10 ^ ERROR at Row:1:Column:147 No such column 'Address' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Stack Trace: null
Error: Compile Error:
PostalCode FROM Lead WHERE DISTANCE(Street,:loc1, 'km') < 60 ORDER BY
^
ERROR at Row:1:Column:103
Invalid field type: ColumnType.MultiLineText. The distance() function supports only fields of type geolocation. at line 12 column 13