4

I recieve the below error when I am trying to call a Custom Lightning Component in a Visualforce page that is used in Communities.

  • Unrecognized Content-Security-Policy directive 'reflected-xss'.
  • logo180.png Failed to load resource: the server responded with a status of 404 (Not Found)
  • CommunityHomePage:1 Uncaught SyntaxError: Unexpected token w in JSON at position 0 at JSON.parse () at XMLHttpRequest.xhr.onreadystatechange (lightning/lightning.out.delegate.js?v=ZCuyRUYzK_kAf4cKCIeS2A:143)
  • My Component

    <aura:component controller="LeadController" implements="forceCommunity:availableForAllPageTypes">
        <aura:attribute name="theLead" 
            type="Lead" 
            default="{ 'sobjectType': 'Lead',
                       'Rating__c': 2,
                       'Company': '',
                       'FirstName': '',
                       'LastName': '',
                       'Email': '' }"/>
        <form>
    
            <ui:inputText value="{!v.theLead.Company}" label="Company" class="input"/>
            <ui:inputText value="{!v.theLead.FirstName}" label="First" class="input"/>
            <ui:inputText value="{!v.theLead.LastName}" label="Last" class="input" />
            <ui:inputEmail value="{!v.theLead.Email}" label="Email" class="input" />
            <ui:button label="Save" press="{!c.save}"/>
        </form>
    </aura:component>
    

    My Lightning App is

    <aura:application access="GLOBAL" extends="ltng:outApp" implements="forceCommunity:availableForAllPageTypes">
        <aura:dependency resource="c:CommunityChatter"/>
    </aura:application>
    

    My VF Page is

    <apex:page standardController="Lead">
        <apex:includeScript value="{!$Site.BaseUrl}/lightning/lightning.out.js"/>
        <script>
            $Lightning.use("c:MyLightApp", function() {
                $Lightning.createComponent(
                    "c:CommunityChatter",
                    {},
                    "theLead",
                    function(cmp) {
                        console.log("Component created!");
                        console.log(cmp);
                    });
                });
        </script>
    
        <div id="theLead"></div>
    </apex:page>
    
    2

    Found the Issue, It is just a Permission on the Profile for Lead.

    • 2
      Could you be more specific? Maybe it will help some people in the future with the same problem. – Martin Lezer Apr 10 '17 at 7:23
    • Hi Martin, Sorry should have been more specific. Details are as below. – user3113331 Apr 20 '17 at 4:44
    0

    Better Answer:

    Since, I was trying to use this component in Customer Communities, I have to make the object available for the customer community profiles.

    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.