I have a query like below in an Apex Class in Sandbox.
query = 'SELECT Id, Name, BillingAddress, BillingLatitude, BillingLongitude FROM Account WHERE Name = \''+ name +'\' AND ';
query += 'DISTANCE(BillingAddress, GEOLOCATION('+lat+', '+lng+'), \'km\') < '+distance+' ORDER BY DISTANCE(BillingAddress, GEOLOCATION('+lat+', '+lng+'), \'km\') ASC';
It works perfect in sandbox. But when I try to deploy this class to live, it generate this error:
System.QueryException: No such column 'BillingAddress' on entity 'Account'. 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.
What are the possible reasons?
BillingAddress
is supported in API version 30 and beyond. In my case, the API versions were correct and still was not able to deploy code, the problem solved somewhat mysteriously. I never knew what was the problem but it just started working.