• Francesco Dessì
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Hi,
In a Community page, I have an LWC whit a Visualforce page embedded with an Iframe.
Everything works fine, but when I load the page with Chrome in incognito mode I the get the error:

Refused to display 'https://……………' in a frame because it set 'X-Frame-Options' to 'deny'

and the visulaforce page does't appear.

Hi!

In a Community Page, I have a LWC with an handler for message events (I use it to intercept message from an iframe).
The problem is that the handler intercepts an infinite number of message events.

For simplicity, we can consider the following LWC:
HTML

<template>
<div>-- COMPONENT TEST --</div>
<div>-- EVENTS: {counter} --</div>
</template>

JAVASCRIPT

import {LightningElement, track, api, wire} from 'lwc';

export default class Test extends LightningElement {

    counter = 0;

    checkEvent(event) {
        console.log('--> Event: ', event.type);
        this.counter++;
    }

    checkEventBind = this.checkEvent.bind(this);

    connectedCallback() {
        console.log('--> connectedCallback');
        if (window.addEventListener) {
            window.addEventListener("message", this.checkEventBind, true);
        } else {
            window.attachEvent("onmessage", this.checkEventBind);
        }
    }

    disconnectedCallback() {
        window.removeEventListener('message', this.checkEventBind, true);
    }
}

Metadata

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>47.0</apiVersion>
    <description>Test</description>
    <isExposed>true</isExposed>
    <masterLabel>Test</masterLabel>
    <targets>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>
 

The error occurs when the LWC is on a Community Page with a Flexible Layout. Clicking anywhere on the page generates an infinite number of message events.

The problem seems related to the Flexible Layout because it doesn’t occur if the LWC is on a Community Page with a full-width column layout.

Another example:

  1. I add the LWC on a Community Page with a Flexible Layout and on a Community Page with a full-width column layout
  2. I first open the Page with the Flexible Layout and then the Page with a full-width column layout
  3. Now, clicking anywhere on the Page with the full-width column layout, starts the generation of an infinite number of message events.

How can I solve the problem?
Do I have to avoid Flexible Layout in my Community?

Hello All,
I need to build a dynamic SOQL where clause based on 15 fields and wanted to see if anyone can recommend a more efficient approach than what I have below:
 
List<Drive__c> lstDrive = [SELECT Id, field1, field2, field3, field4, field5, field 6, field 7 FROM Drive__c where Id=:currentId LIMIT 1];

If(!lstDrive.isEmpty()){

Drive__c currentDrive = lstDrive[0];
String myQuery = 'SELET Id FROM Account Where ';

if(currentDrive.field1 != null) {
myQuery += 'field1 >= ' + currentDrive.field1 + ' AND ';
}
if(currentDrive.field2 != null) {
myQuery += 'field2 >= ' + currentDrive.field2 + ' AND ';
}
if(currentDrive.field3 != null) {
myQuery += 'field3 <=' + currentDrive.field3 + ' AND ';
}
.
.
.
.
}
List<Account> result = Database.query(myQuery);
Basically, I have 15 such 'if' blocks that build the where clause.  Any suggestions or recommendation would be greatly appreciated.
  • February 17, 2021
  • Like
  • 0

Hi,
In a Community page, I have an LWC whit a Visualforce page embedded with an Iframe.
Everything works fine, but when I load the page with Chrome in incognito mode I the get the error:

Refused to display 'https://……………' in a frame because it set 'X-Frame-Options' to 'deny'

and the visulaforce page does't appear.