1

I need some inputs for below issue.

Trying to use Google Translation and Google Captcha in Lightning Component. For this, we were using the scripts provided by Google as below. Google Translate : ‘https://translate.google.com/manager/website/’ Google ReCAPTCHA : ‘https://www.google.com/recaptcha/admin#list

For allowing using third party javascript in salesforce, we have mentioned them under 'CSP'. Though as per Spring'2017 release notes of salesforce, You can’t load JavaScript resources from a third-party site, even a CSP Trusted Site. To use a JavaScript library from a third-party site, add it to a static resource, and then add the static resource to your component. After the library is loaded from the static resource, you can use it as normal.

Though as for Captcha, it is dynamically generated each time, it is not recommended to store this javascript. Please find below link for same. Is it possible to have Google reCaptcha in a custom Lightning Component?

Also, the javascript code for these uses syntax like "", "eval" etc which are not allowed in lightning components, hence we are not directly able to use same code in static resources.

Is there any other way to use these in salesforce lightning?

Thanks,

Garima

1

Yes this can be done, by creating a VisualForce page containing the captcha script and embedding the VF page in an IFrame in your lightning component.

A great example by Miguel Duarte can be found here: http://www.rightitservices.com/articles/423-google-recaptcha-v2-in-salesforce-custom-lightning-component

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.