+ Start a Discussion
Big EarsBig Ears 

Using DISTANCE in a SOQL query - Retrieving and presenting the distance

As of Spring '16, we can now retrieve the distance, as well as sort/filter by it:

https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_api_soql.htm

However, the documentation doesn't seem to indicate how we are supposed to access and retrieve this value from the returned results. It just seems to not be included along with the other columns.

Has anybody else used this functionality? It would be very useful to get my head around it.

Andy
Best Answer chosen by Big Ears
Big EarsBig Ears
I found the answer on Stackexchange. You use Aliasing and the .get() notation to get the alias.

http://salesforce.stackexchange.com/questions/37046/can-geolocation-fields-be-used-to-calculate-and-display-distance