I generated a community page from Salesforce Survey tools, I then have this kind of community URL : https://dev-example.cs162.force.com/something. Now I want to display that URL within a Lightning Page. For that I created a LWC where I embed that url within an iFrame. But whenever I load the Lightning page (from Google Chrome), I have this error on the iFrame: enter image description here

While I've done the following :

  • I added https://dev-example.cs162.force.com to CSP Trusted Sites
  • I made this config on my Sandbox org :enter image description here

enter image description here

  • I also made this config on Community sites : enter image description here

But nothing works, I still have the message : dev-example.cs162.force.com refused to connect.

Please help, what can I do to make that community page available within an iFrame on Salesforce Lightning Page !?

By the way, here is the LWC code details:

  • Html
        <lightning-card  title="Survey" icon-name="custom:custom59">
            <div class="slds-m-around_medium slds-grid_vertical-stretch" >
                <iframe frameborder=0 width="100%" height="800px"   src={invitationLink}></iframe>
  • JS
import { LightningElement, api, wire, track } from 'lwc'
import retrieveLastSurveyInvitationLink from '@salesforce/apex/SurveyIframeController.retrieveLastSurveyInvitationLink'
export default class SurveyIframe extends LightningElement {
    @track invitationLink = ''
    @api recordId

    @wire(retrieveLastSurveyInvitationLink, {recordId: '$recordId'}) 
    retrieveLastSurveyInvitationLink({error, data}){
        console.log('JSON.stringify(data)', JSON.stringify(data))
        this.invitationLink = data
      }else if(error){
        console.log('retrieveLastSurveyInvitationLink error', JSON.stringify(error))
  • Apex
public class SurveyIframeController {

    public static String retrieveLastSurveyInvitationLink(Id recordId){
        String invitationLink = null;
        Visit__c visit = [SELECT SurveyInvitation__r.InvitationLink 
                            FROM Visit__c 
                            WHERE Id=:recordId 
                            LIMIT 1];
        invitationLink = Test.isRunningTest() ? 'testUrl' : visit.SurveyInvitation__r.InvitationLink;
        return invitationLink;

Thank You

  • Could you share the LWC code ? At least the code portion showing where the url is embedded as iframe
    – Shamina
    Jul 24, 2022 at 18:47
  • @Shamina DONE! Thank you!
    – kabrice
    Jul 25, 2022 at 0:49
  • include the details of browser console log, there can be further details on the error there
    – Shamina
    Jul 25, 2022 at 13:57
  • @Shamina Here is the error triggers by the browser console log :Refused to frame 'https://dev-example.cs162.force.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".
    – kabrice
    Jul 26, 2022 at 7:58
  • 1
    It's weird, the embedding does work when I don't generate my survey with community
    – kabrice
    Jul 28, 2022 at 8:33

3 Answers 3


Did you check under Session Settings | Trusted Domains for Inline Frames? In this section it is possible to add host that are origin of content that is being imbedded via iframe. And you can use with clickjack protection enabled and with clickjack protection in more restrictive level than yours in communities settings, since add trusted domains are exception to the behavior of block embed code from iframe.

By the domain of community I supposed that is the same host of visualforce page. And I have to do similar config to embed a visualforce page inside an iframe in a Lightning component (Aura). If it is the scenario that you don't set this yet, you could allow the url of your community or using wildcard as *.force.com, thus all content from this origin should be allow be embedded by iframe (the limit is 512 entries for allowed domains). In settings of community sites has the same section to add hosts that are allowed to be embedded.


Add More Trusted Domains for Inline Frames

Enable Clickjack Protection in Experience Cloud Sites

  • All of these have already been done, and nothing works.
    – kabrice
    Jul 26, 2022 at 8:12

This looks like licensing issue to me. Salesforce offers 3 different licenses to use surveys. Survey Response Pack, Feedback Management - Starter and Feedback Management - Growth. The ability to use surveys on external website/communities differ based on the licenses.For "Survey Response Pack", surveys cannot be included in communities/external websites while "Feedback Management - Starter" includes ability to include it in communities only and "Feedback Management - Growth" includes ability to include in community+external website. Also it seems that Salesforce has additional settings to enable this feature even though you may have this licnese. I would suggest you check the license and talk to your Account Executive.

  • Please can you add your sources and references? I can't see what you're saying on : salesforce.com/editions-pricing/platform/feedback-management
    – kabrice
    Jul 26, 2022 at 9:45
  • I had faced similar issue. Information is provided by Salesforce support and Salesforce AE. Somewhat close here - help.salesforce.com/s/…
    – ManishG
    Jul 26, 2022 at 10:14
  • As I told before, I don't think one of those licenses is mandatory to use Salesforce Survey, I don't think I've one of them, I just have "Salesforce Unlimited Edition"
    – kabrice
    Jul 26, 2022 at 12:25
  • It's weird, the embedding does work when I don't generate my survey with community
    – kabrice
    Jul 28, 2022 at 8:33

From this idea:

"...Unfortunately it is currently impossible to embed Lightning pages (platform or community) in iframes"


"...Salesforce PMs would not allow this because of the security implications."

  • It's weird, the embedding does work when I don't generate my survey with community
    – kabrice
    Jul 28, 2022 at 8:33
  • The idea pointed is onother scenario, embed the Salesforce in third-party applications via iframe. It was allowed for classic, but not for Lightning Experience. Jul 28, 2022 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .