• Shane K 8
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hello,

I have a visualforce page that has link to a record id, when left click the link the record opens fine. When I right on that link and choose "Open link in a new tab" a new tab opens but the the URL is "about:blank#blocked".  How can I display the record page in the new tab?

Thanks.
Hello,

I am getting this error when calling the CalloutClass from test method.

Method does not exist or incorrect signature: void getParams(Id) from the type CalloutClass
public class CalloutClass {
    
    @future (callout=true)
    public static void getParams(List<Id> Ids)
    {
        try{
            //logic
            
        }
        catch (Exception e) {
            system.debug(e);
        }
        
    }
}
 
@isTest

public class CalloutClassTest {
    static testMethod void testMethod() {
        
        ObjX__c testX = new ObjX__c();
        testx.Name = 'test record' ;
        insert testX;
        
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = CalloutClass.getParams(testX.id);
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"example":"test"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        
    }
}
 
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('http://example.com/example/test', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"example":"test"}');
        res.setStatusCode(200);
        return res;
    }
}



 
Hello,

How can I return lat and lon from the class? I am passing Address to the getLatitude_Longitude method and would like to return the lat and lon.
 
public class GetMapLocation {
     @future (callout=true)
    static public void getLatitude_Longitude(String Address){
        
        Address = EncodingUtil.urlEncode(Address, 'UTF-8');
        
        // build callout
        Http h = new Http();        
        HttpRequest req = new HttpRequest();
        
	    String yourAPiKey = 'MyKey'; // Enter your Api key which you have created in google api console
        String key = '&key=' + yourAPiKey;
        String endPoint = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + Address;
		
        req.setEndpoint(endPoint + key);
        req.setMethod('GET');
        req.setTimeout(5000);
        System.debug('Request ' + req);
        try{
            // callout
            HttpResponse res = h.send(req);
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            system.debug('Response get Body ' + res.getBody());
            
            double lat = null;
            double lon = null;
            //system.debug(parser.nextToken());
            while (parser.nextToken() != null) {  
                system.debug(parser.getCurrentToken());
                system.debug(JSONToken.FIELD_NAME);
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       // system.debug('a');
                        parser.nextToken(); // object start                     
                        while (parser.nextToken() != JSONToken.END_OBJECT){
                            String txt = parser.getText();
                            parser.nextToken();
                            if (txt == 'lat')
                                lat = parser.getDoubleValue();
                            else if (txt == 'lng')
                                lon = parser.getDoubleValue();
                        }
                    }
            }
            // update coordinates if we get back
            system.debug(lat);
            if (lat != null){
                system.debug(lat+' '+lon);              
            }
        }
        catch (Exception e) {
            system.debug(e);
        }
    }
}

 
We have this code in our org for a trigger. I am trying to understand the code. Can anyone please explain what's being done in the bolded lines?
 
public with sharing class ObjAction {
    private Obj__c[] newObj;  
    private Obj__c[] oldObj; 
    ObjHandler triggerHandler = new ObjHandler();
    public ObjAction(Obj__c[] oldObj, Obj__c[] newObj){    
        this.newObj = newObj;    
        this.oldObj = oldObj;   
    } 
}

Thanks.
Hello,

Is it possible to achieve this functionality?

I would like to override the standard New button with visualforce page, which I know is possible, but based on some criteria I want to call a either a custom lightning component or the standard New button functionality. I will be using a controller to check my criteria but want to know how to use the standard New button functionality if the criteria does not meet. How to leverage the standard New button functionality?

Thanks.
Hello,

I have a visualforce page that has link to a record id, when left click the link the record opens fine. When I right on that link and choose "Open link in a new tab" a new tab opens but the the URL is "about:blank#blocked".  How can I display the record page in the new tab?

Thanks.
Hello,

I am getting this error when calling the CalloutClass from test method.

Method does not exist or incorrect signature: void getParams(Id) from the type CalloutClass
public class CalloutClass {
    
    @future (callout=true)
    public static void getParams(List<Id> Ids)
    {
        try{
            //logic
            
        }
        catch (Exception e) {
            system.debug(e);
        }
        
    }
}
 
@isTest

public class CalloutClassTest {
    static testMethod void testMethod() {
        
        ObjX__c testX = new ObjX__c();
        testx.Name = 'test record' ;
        insert testX;
        
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = CalloutClass.getParams(testX.id);
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"example":"test"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        
    }
}
 
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('http://example.com/example/test', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"example":"test"}');
        res.setStatusCode(200);
        return res;
    }
}



 
Hello,

How can I return lat and lon from the class? I am passing Address to the getLatitude_Longitude method and would like to return the lat and lon.
 
public class GetMapLocation {
     @future (callout=true)
    static public void getLatitude_Longitude(String Address){
        
        Address = EncodingUtil.urlEncode(Address, 'UTF-8');
        
        // build callout
        Http h = new Http();        
        HttpRequest req = new HttpRequest();
        
	    String yourAPiKey = 'MyKey'; // Enter your Api key which you have created in google api console
        String key = '&key=' + yourAPiKey;
        String endPoint = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + Address;
		
        req.setEndpoint(endPoint + key);
        req.setMethod('GET');
        req.setTimeout(5000);
        System.debug('Request ' + req);
        try{
            // callout
            HttpResponse res = h.send(req);
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            system.debug('Response get Body ' + res.getBody());
            
            double lat = null;
            double lon = null;
            //system.debug(parser.nextToken());
            while (parser.nextToken() != null) {  
                system.debug(parser.getCurrentToken());
                system.debug(JSONToken.FIELD_NAME);
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       // system.debug('a');
                        parser.nextToken(); // object start                     
                        while (parser.nextToken() != JSONToken.END_OBJECT){
                            String txt = parser.getText();
                            parser.nextToken();
                            if (txt == 'lat')
                                lat = parser.getDoubleValue();
                            else if (txt == 'lng')
                                lon = parser.getDoubleValue();
                        }
                    }
            }
            // update coordinates if we get back
            system.debug(lat);
            if (lat != null){
                system.debug(lat+' '+lon);              
            }
        }
        catch (Exception e) {
            system.debug(e);
        }
    }
}

 
We have this code in our org for a trigger. I am trying to understand the code. Can anyone please explain what's being done in the bolded lines?
 
public with sharing class ObjAction {
    private Obj__c[] newObj;  
    private Obj__c[] oldObj; 
    ObjHandler triggerHandler = new ObjHandler();
    public ObjAction(Obj__c[] oldObj, Obj__c[] newObj){    
        this.newObj = newObj;    
        this.oldObj = oldObj;   
    } 
}

Thanks.