• Eric Anderson 86
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
I am attempting to implement reCaptcha on my visual force page and regardless of the type of verification level I request (Version 2 or version 3) I get the same error message. The following is the code from my Visualforce page:
 
<apex:page controller="Captcha" cache="false">
<apex:pageBlock title="Captcha Verification">
<apex:form >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputName" value="Name"/>
<apex:inputText value="{!myName}" id="inputName"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputEmail" value="Email"/>
<apex:inputText value="{!myEmail}" id="inputEmail"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! NOT(verified)}">
<script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k={!publicKey}">
</script>
<noscript>
<iframe src="https://www.google.com/recaptcha/api/noscript?k={!publicKey}" height="300" width="500" frameborder="0">
</iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton action="{!verify}" value="Check If I’m Human" rendered="{! NOT(verified)}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!verified}">
<p>reCAPTCHA verification suggests that you’re not a ‘bot.</p>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
</apex:page>
The following is my Apex code:
public class Captcha {
    public boolean checkCurrentValue{get;set;}
    public String challenge{get;set;}
    public String response{get;set;}
    public String publicKey {get;set;}
    private static String privateKey = '6Lf_E3sUAAAAAD936kuwlhIPCBua-oj7zWVZANg7';
    // change this key to the key which we you have  generated after click on server side integration which is “secret”
    private static String baseUrl = 'https://www.google.com/recaptcha/api/siteverify';
    public String myName { get; set; }
    public String myEmail { get; set; }
    public Boolean verified { get; private set; }
    public Captcha()
    {
        publicKey = '6Lf_E3sUAAAAAMNCGpOZ-VtGCNyQI641CrEccALh';
// we can get this key when we click on client site integration with “data-sitekey=”6LeHD3kUAAAAAL2tHSW8jgnaUQBDvEpOb6y0iUOJ”
        this.verified = false;
        checkCurrentValue=false;
        challenge = ApexPages.currentPage().getParameters().get('recaptcha_challenge_field');
        response =  ApexPages.currentPage().getParameters().get('recaptcha_response_field');
    }
    public PageReference verify()
    {
        System.debug('reCAPTCHA verification attempt');
        // On first page load, form is empty, so no request to make yet
        if ( challenge == null || response == null )
        {
            System.debug('reCAPTCHA verification attempt with empty form');
            return null;
        }
        HttpResponse r = makeRequest(baseUrl,'privatekey=' + privateKey + '&remoteip='  + remoteHost + '&challenge=' + challenge + '&response='  + response);
        if ( r!= null )
        {
            this.verified = (r.getBody().startsWithIgnoreCase('true'));
        }
        if(this.verified)
        {
            // If they pass verification, you might do something interesting here
            // Or simply return a PageReference to the “next” page
            return null;
        }
        else
        {
            // stay on page to re-try reCAPTCHA
            return null;
        }
    }
    public PageReference reset()
    {
        return null;
    }  
    /* Helper methods */
    private static HttpResponse makeRequest(string url, string body) 
    {
        HttpResponse response = null;
        HttpRequest req = new HttpRequest();  
        req.setEndpoint(url);
        req.setMethod('POST');
        req.setBody (body);
        try
        {
            Http http = new Http();
            response = http.send(req);
            System.debug('reCAPTCHA response: ' + response);
            System.debug('reCAPTCHA body: ' + response.getBody());
        }
        catch(System.Exception e)
        {
            System.debug('ERROR: ' + e);
        }
        return response;
    }
    private String remoteHost
    {
        get {
            String ret = '127.0.0.1';
            // also could use x-original-remote-host
            Map<String, String> hdrs = ApexPages.currentPage().getHeaders();
            if (hdrs.get('x-original-remote-addr')!= null)
                ret =  hdrs.get('x-original-remote-addr');
            else if (hdrs.get('X-Salesforce-SIP')!= null)
                ret =  hdrs.get('X-Salesforce-SIP');
            return ret;
        }
    } 

}
Since I am still in 'development' in my sandbox, the domain that I entered was

cdcrca--ombudsman.cs33.my.salesforce.com

The error message I am getting is the following (even though as I said, I have tried version 2 and 3 and 1 is not even available any more:
Image of error message I am getting.

Any assistance would be greatly appreciated.

Thank you! - Eric -

 
Hi there everyone,

I have a set of custom objects. One called ‘Research task’ and another called ‘Correspondence’. The ‘Correspondence’ custom object is a child object to the ‘Research Task’ object, which is the parent.  The customer occasionally receives an e-mail that results in either the creation of a new custom object ‘Research Task’ object entry into Salesforce or a ‘Correspondence’ to an existing ‘Research Task’. If the e-mail that is received is something new that has never been researched, the customer would like to select an Assignee from drop down, as well as a priority, and then have the body of the e-mail placed in the initial ‘Correspondence’ entries text field for this new ‘Research Task’. If the e-mail is relating to an existing ‘Research Task’ the user would like to be able to select the Research Task from a drop down list and then have the context of the e-mail placed in a new ‘Correspondence’ entry.

My question is, ‘Does this functionality currently existing in the Outlook integration or, is this something we would need to create a custom solution for? (I am presuming the later.) 

If this is something that we would need to create a custom solution for, would this be done using something like ‘Visual Force’ that might give the user the ability to look at e-mails and give the user the ability to either create a new case, or add information to an existing case?
Does anyone have an example of something like this that they can at least share some guidance in regards this topic with me?

Thank you in advance for your assistance.

Respectfully,

Eric Anderson
 
Hi there,

We have a requirement that the search process within our Lightning application not only search the custom objects within our application, but any files attached to a given case, just like 'Classic' does. Through using what I learned in the 'Trailhead' on custom themes and creating a custom search component, I was able to add the 'Custom Objects' to the search and get it to return the rows, but I'm at a loss on how to get it to search my attachments. 

Any suggestions would be greatly appreciated. 

Thanks! - Eric- 
I am attempting to implement reCaptcha on my visual force page and regardless of the type of verification level I request (Version 2 or version 3) I get the same error message. The following is the code from my Visualforce page:
 
<apex:page controller="Captcha" cache="false">
<apex:pageBlock title="Captcha Verification">
<apex:form >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputName" value="Name"/>
<apex:inputText value="{!myName}" id="inputName"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputEmail" value="Email"/>
<apex:inputText value="{!myEmail}" id="inputEmail"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! NOT(verified)}">
<script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k={!publicKey}">
</script>
<noscript>
<iframe src="https://www.google.com/recaptcha/api/noscript?k={!publicKey}" height="300" width="500" frameborder="0">
</iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton action="{!verify}" value="Check If I’m Human" rendered="{! NOT(verified)}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!verified}">
<p>reCAPTCHA verification suggests that you’re not a ‘bot.</p>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
</apex:page>
The following is my Apex code:
public class Captcha {
    public boolean checkCurrentValue{get;set;}
    public String challenge{get;set;}
    public String response{get;set;}
    public String publicKey {get;set;}
    private static String privateKey = '6Lf_E3sUAAAAAD936kuwlhIPCBua-oj7zWVZANg7';
    // change this key to the key which we you have  generated after click on server side integration which is “secret”
    private static String baseUrl = 'https://www.google.com/recaptcha/api/siteverify';
    public String myName { get; set; }
    public String myEmail { get; set; }
    public Boolean verified { get; private set; }
    public Captcha()
    {
        publicKey = '6Lf_E3sUAAAAAMNCGpOZ-VtGCNyQI641CrEccALh';
// we can get this key when we click on client site integration with “data-sitekey=”6LeHD3kUAAAAAL2tHSW8jgnaUQBDvEpOb6y0iUOJ”
        this.verified = false;
        checkCurrentValue=false;
        challenge = ApexPages.currentPage().getParameters().get('recaptcha_challenge_field');
        response =  ApexPages.currentPage().getParameters().get('recaptcha_response_field');
    }
    public PageReference verify()
    {
        System.debug('reCAPTCHA verification attempt');
        // On first page load, form is empty, so no request to make yet
        if ( challenge == null || response == null )
        {
            System.debug('reCAPTCHA verification attempt with empty form');
            return null;
        }
        HttpResponse r = makeRequest(baseUrl,'privatekey=' + privateKey + '&remoteip='  + remoteHost + '&challenge=' + challenge + '&response='  + response);
        if ( r!= null )
        {
            this.verified = (r.getBody().startsWithIgnoreCase('true'));
        }
        if(this.verified)
        {
            // If they pass verification, you might do something interesting here
            // Or simply return a PageReference to the “next” page
            return null;
        }
        else
        {
            // stay on page to re-try reCAPTCHA
            return null;
        }
    }
    public PageReference reset()
    {
        return null;
    }  
    /* Helper methods */
    private static HttpResponse makeRequest(string url, string body) 
    {
        HttpResponse response = null;
        HttpRequest req = new HttpRequest();  
        req.setEndpoint(url);
        req.setMethod('POST');
        req.setBody (body);
        try
        {
            Http http = new Http();
            response = http.send(req);
            System.debug('reCAPTCHA response: ' + response);
            System.debug('reCAPTCHA body: ' + response.getBody());
        }
        catch(System.Exception e)
        {
            System.debug('ERROR: ' + e);
        }
        return response;
    }
    private String remoteHost
    {
        get {
            String ret = '127.0.0.1';
            // also could use x-original-remote-host
            Map<String, String> hdrs = ApexPages.currentPage().getHeaders();
            if (hdrs.get('x-original-remote-addr')!= null)
                ret =  hdrs.get('x-original-remote-addr');
            else if (hdrs.get('X-Salesforce-SIP')!= null)
                ret =  hdrs.get('X-Salesforce-SIP');
            return ret;
        }
    } 

}
Since I am still in 'development' in my sandbox, the domain that I entered was

cdcrca--ombudsman.cs33.my.salesforce.com

The error message I am getting is the following (even though as I said, I have tried version 2 and 3 and 1 is not even available any more:
Image of error message I am getting.

Any assistance would be greatly appreciated.

Thank you! - Eric -