+ Start a Discussion
Aparna Hegde 8Aparna Hegde 8 

I am trying to run this on developer console - execute anonymous. Getting error

public without sharing class LawyerAddressAllocationSelector {

    public Map< Lawyer_Address_Allocation__c,String> selectByClosest(List<Id> lawyerIds, Double latitude, Double longitude) {
         Map< Lawyer_Address_Allocation__c,String>  DistWithAddr = new Map< Lawyer_Address_Allocation__c,String>();  
    for (Lawyer_Address_Allocation__c record:[Select Id,Start_Time__c, End_Time__c, Lawyer_Name__c, Lawyer_Name__r.Name,
                Office_Address__c, Office_Address__r.Geo_Coordinate__c,DISTANCE(Office_Address__r.Geo_Coordinate__c, GEOLOCATION(:latitude, :longitude), 'km') Dist
            From Lawyer_Address_Allocation__c
            Where (
                (Start_Time__c = null And End_Time__c = null)
                Or (Start_Time__c !=null And End_Time__c != null And End_Time__c >= TODAY)
            ) And Office_Address__c!=null AND Lawyer_Name__c in: lawyerIds
            Order by DISTANCE(Office_Address__r.Geo_Coordinate__c, GEOLOCATION(:latitude, :longitude), 'km'), Primary__c
            Limit 10000
    system.debug('Return'+ DistWithAddr) ;                                        }
    return DistWithAddr;

List<Id> Lid=new List<Id>();

Line: 4, Column: 33
Method does not exist or incorrect signature: void selectByClosest(List<Id>, Decimal, Decimal) from the type LawyerAddressAllocationSelector
Sunil RathoreSunil Rathore
Hi Aparna,

Greetings to you!!!

Your selectByClosest  method is not a static method so you cannot call this method directly with the class name.

You have to make a instance of your class and then call you method. 

Please refer this:
LawyerAddressAllocationSelector objClass = new LawyerAddressAllocationSelector();

Please refer this link for more details:

Hope this will help you. If does then mark it as the best answer so it can also help others in the future.

Many Thanks,
Sunil Rathore