+ Start a Discussion
Erik John PErik John P 

works in anonymous editor, not in class?

hello,
lookinf for some assistance from the dev folks.  I am but a lowly admin :-).  any help is appreciated.
this works Anonymous editor:
String leadId_in = '00Q5B000003JcHYUA0';
String company_in = 'TS00120';
    
    
        String companyIS = company_in; 
        
        // need to return fewer columns
        Lead[] lds = 
            [select Lead.Id, Lead.Geocode_Quality__c, Lead.Geolocation__Latitude__s, 
             Lead.Geolocation__Longitude__s, Lead.Distance_for_Delivery_Charge__c, Lead.Company 
             from Lead where Lead.Id = :leadId_in and Lead.Company = :companyIS
            ];
        
        //debug: leads returned in query
        System.debug('Lead count anonymous: ' + lds.size()); 



this doesn't work in class:

public class FindDeliveryDistance {
    
    
    private Lead[] lds = null; 
    private Location companyLoc = null; 
    private String companyIS = null; 

    
    /**
    * Use lead_id and Company name to select lead data. 
    * 
    */    
    public FindDeliveryDistance(String leadId_in, String company_in){
        
        System.debug('leadId_in: ' + leadId_in); 
        System.debug('company_in: ' + company_in); 

        
        companyIS = company_in; 
        
        // need to return fewer columns
        lds = 
            [select Lead.Id, Lead.Geocode_Quality__c, Lead.Geolocation__Latitude__s, 
             Lead.Geolocation__Longitude__s, Lead.Distance_for_Delivery_Charge__c, Lead.Company 
             from Lead where Lead.Id = :leadId_in and Lead.Company = :companyIS
            ];
        
        //debug: leads returned in query
        System.debug('Lead count: ' + lds.size()); 

    } }

what am I doing wrong?
v varaprasadv varaprasad
Hi Eric .

please Check once following code : 
 
public class FindDeliveryDistance {
    
    
    public list<lead> lds = null; 
    public Location companyLoc = null; 
    public String companyIS = null; 

    
    /**
    * Use lead_id and Company name to select lead data. 
    * 
    */    
    public FindDeliveryDistance(String leadId_in, String company_in){
        
        System.debug('leadId_in: ' + leadId_in); 
        System.debug('company_in: ' + company_in); 
        lds = new list<lead>();
        
        companyIS = company_in; 
        
        // need to return fewer columns
        lds = 
            [select Id, Geocode_Quality__c, Geolocation__Latitude__s, 
             Geolocation__Longitude__s, Distance_for_Delivery_Charge__c, Company 
             from Lead where Id =:leadId_in and Company = :companyIS];
        
        //debug: leads returned in query
        System.debug('Lead count: ' + lds.size()); 

    } 
}

Hope this helps you!

Thanks
Varaprasad
For Support: varaprasad4sfdc@gmail.com


 
Erik John PErik John P
Hello Varaprasad,

My Internal developer tried this and was not successful.  he sent me some notes that I have inserted below:

In APEX,
 
changing Lead[]  to List<Lead> does not do anything? 
 
List<Lead> is a
List collection for type Lead and List has a lot of features.  Lead[] looks wrong.


Here is the log data:
20:51:49.37 (61499537)|USER_DEBUG|[15]|DEBUG|leadId_in: 00Q5B000003JcHYUA0

20:51:49.37 (61548458)|USER_DEBUG|[16]|DEBUG|company_in: TS00120
20:51:49.37 (66443222)|USER_DEBUG|[29]|DEBUG|Lead count: 0
20:51:49.37 (67289516)|USER_DEBUG|[39]|DEBUG|Distance before computation: -1.0
 
Still not copying query results to the Lead array.

I may see if I can have him respond directly, and thank you for your support.