An effort to bring a revolution in Salesforce.

Wednesday, 22 July 2015

Force.com Summer '15 Release Location and Distance Variables Allowed in SOQL and SOSL Queries

 
 
SOQL and SOSL statements in Apex can reference Apex code variables and expressions if they’re preceded by a colon (:). This use of a local code variable within a SOQL or SOSL statement is called a bind. The Apex parser first evaluates the local variable in code context before executing the SOQL or SOSL statement. Double myLatitude = 10; Double myLongitude = 10; List accountList = [SELECT Id, Name, BillingLatitude, BillingLongitude FROM Account WHERE DISTANCE(My_Location_Field__c, GEOLOCATION(:myLatitude, :myLongitude), 'mi') < 10]; Location myLocation = Location.newInstance(10, 10); Double myDistance = 100; List accountList = [SELECT Id, Name, BillingLatitude, BillingLongitude FROM Account WHERE DISTANCE(My_Location_Field__c, :myLocation, 'mi') < :myDistance];

No comments:

Post a Comment

Get Gmail, Docs, Drive, and Calendar for business