function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Roberto NistiRoberto Nisti 

Try instantiated a constructor but doesn't work

Hello,

I try instaciated a constructor as:


                 string address1 = CheckAndFeed.descricaoenderecouser(terapeutaId);
                string address2 = CheckAndFeed.descricaoendereco(accId);
                
                googlemaps gerarota = new googlemaps(address1, address2);


And my constructor is:

public class googleMaps {

    public String duration {get;set;}
    public Integer travelTime {get;set;}
    public Decimal distance {get;set;}
    
    public googleMaps (
            String address1,
            String address2) {
        
        system.debug('In google maps');
        String jsonResults = getJsonResults(address1, address2);
        system.debug('After Json');
...

It doesn't work, object isn't instatiated. I don't know why.
SandhyaSandhya (Salesforce Developers) 
Hi,

I have tried your code and instance is created,  system.debug('In google maps'); is printed. There might be some problem in your getJsonResults(address1, address2); method.

Best Regards,
Sandhya