You need to sign in to do that
Don't have an account?
Cheyne
Location based SOQL query using AJAX toolkit
I'm trying to run a location based SOQL query from javascript, using the AJAX toolkit, and I'm getting an error telling me that the location field is not defined. I have geolocation field, called Location__c, defined on the Contact. Here is my code:
<apex:page >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="../soap/ajax/25.0/connection.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
sforce.connection.sessionId = '{!$Api.Session_ID}';
var query = "SELECT Id FROM Contact WHERE DISTANCE(Location__c, GEOLOCATION(42.0, -76.0), 'mi') < 10";
console.log(query);
var res = sforce.connection.query(query);
console.log(res);
});
</script>
</apex:page>
The post request is returning a 500 error, with the message, "No such column 'Location__c' on entity 'Contact'." However, there is a field called Location__c; furthermore, this query works just fine from the Developer Console. Can anyone see what might be going on here?
<apex:page >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="../soap/ajax/25.0/connection.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
sforce.connection.sessionId = '{!$Api.Session_ID}';
var query = "SELECT Id FROM Contact WHERE DISTANCE(Location__c, GEOLOCATION(42.0, -76.0), 'mi') < 10";
console.log(query);
var res = sforce.connection.query(query);
console.log(res);
});
</script>
</apex:page>
The post request is returning a 500 error, with the message, "No such column 'Location__c' on entity 'Contact'." However, there is a field called Location__c; furthermore, this query works just fine from the Developer Console. Can anyone see what might be going on here?
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AakZIAS
<script type="text/javascript" src="../soap/ajax/25.0/connection.js" ></script>
to
<script type="text/javascript" src="../soap/ajax/26.0/connection.js" ></script>
did the trick.