I just noticed that one of my queries is no longer working in my sandbox after the Spring '18 has been applied to that sandbox.

In particular this is the error SF is returning:

[object Object]: 'mi') < 55 ORDER BY DISTANCE(someObject__c.Geo_Location__c, GEOLOCATION(33.4589034 ^ ERROR at Row:1:Column:199 field 'Geo_Location__c' can not be sorted in a query call

The WHERE clause in my query breaks it and here's what that where clause looks like:

DISTANCE(someObject__c.Geo_Location__c, GEOLOCATION(33.4589034, -112.0889634), 'mi') < 55 ORDER BY DISTANCE(someObject__c.Geo_Location__c, GEOLOCATION(33.4589034, -112.0889634), 'mi')

The Geo_Location__c field is a geolocation type field. This is still working in Winter '18.

Do you know why this change was applied and if there's a workaround this?

EDIT I can see that their documentation supports this particular piece of code. It's inside one of their examples: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_geolocate.htm

enter image description here

LATEST SF UPDATE ON THIS Salesforce says this has now been fixed.

  • 1
    For what it is worth. The sample Order By clause using DISTANCE is working for me in a prerelease org that is on Spring `18. Both as a direct SOQL query and anonymous Apex. Jan 9, 2018 at 0:14

2 Answers 2


Noticed the same issue this Monday. Here is the mot recent update from SF Support them (got at 8am EST today)

Hi Evgeny,

Good day!

Thank you for your heads up.

We noticed this is as a spring 18 release behavior.Our higher team has raised investigation with our research and development team where they are investigating the issue.

As of now this issue seems to be on only some instances.I will let you know the updates accordingly.

Next Update:Today 4-5 pm EST

  • 1
    Hello All, FYI SF released KI link related to the issue Please hit "THIS ISSUE AFFECTS ME" button so that you will be notified for any update. success.salesforce.com/…
    – WebSolo
    Jan 10, 2018 at 20:19
  • 1
    Also comments from SF Support: We are making sure this doesn't hit the production. Cce team will be reviewing it sooner rather than later. We will be reaching R&D and will request them to expedite.
    – WebSolo
    Jan 10, 2018 at 20:23
  • 1
    New update fro SF Support: Good day! I am following up with my higher team.I could see this is planning to be fixed by this week end. I will let you know the updates day by day. Thank you so much for your patience.
    – WebSolo
    Jan 11, 2018 at 21:11
  • 1
    SF Support updated me with following yesterday: Good day! Our team has scheduled the fix for today.Probably this issue will be fixed by today EOD and you can see the change in functioning by tomorrow. As per tests this morning issue fixed and work as expected I will follow up with you tomorrow so that we can check regarding the functioning.
    – WebSolo
    Jan 17, 2018 at 10:54
  • 1
    Check here for the fix rollout: success.salesforce.com/…
    – WebSolo
    Jan 17, 2018 at 10:55

What instance is your sandbox? I have the same problem in one client's sandbox (CS9) but not in another client's sandbox (CS17) even though both are at Spring 18. In the CS9 sandbox, I even created another Geolocation field in a different object but the ORDER BY DISTANCE fails to compile for that object as well.

I have opened a case with Salesforce premier support, will update here when I have more info.

Update: It's now a Known Issue and supposed to be included in the 5.0 patch, but there's no release date yet.

  • 1
    We also have the same issue. we have also opened a ticket with premier support
    – RedDevil
    Jan 9, 2018 at 2:52
  • We are experiencing this issue in 2 sandboxes. So far that's CS77 and CS19.
    – Arthlete
    Jan 9, 2018 at 4:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .