1

What I did

Aura Component

<aura:component>
    <lightning:flow aura:id="flowData"/>
</aura:component>

Controller

({
    init: function (component, event, helper) {
        console.log('Hello world from Component');
        var flow = cmp.find("flowData");
        flow.startFlow("Self_Registration");
    }
})

Aura App

<aura:application access="Global" extends="ltng:outApp" implements="ltng:allowGuestAccess">
    <aura:dependency resource="c:externalLeadGenerator"/>
</aura:application>

Controller

({
    init: function (component, event, helper) {
        console.log('Hello world from App');
    }
})

My website (running WordPress) is whitelisted in CORS.

This is an HTML code embedded on my page.

<!-- wp:html -->
<script src="https://ajfmo-developer-edition.na174.force.com/pmc/lightning/lightning.out.js"></script>
<script>
    $Lightning.use("c:leadGeneratorApp",    // name of the Lightning app
        function() {                  // Callback once framework and app loaded
            $Lightning.createComponent(
                "c:externalLeadGenerator", // top-level component of your app
                { },                  // attributes to set on the component when created
                "lightningLocator",   // the DOM location to insert the component
                function(cmp) {
                    console.log('Hi from callback');// callback when component is created and active on the page
                }
            );
        }, 'https://ajfmo-developer-edition.na174.force.com/pmc'  // Community endpoint
    );
</script>
<!-- /wp:html -->

<!-- wp:paragraph -->
<div id="lightningLocator">
<p>Something</p>
</div>
<!-- /wp:paragraph -->

This is the result.

enter image description here


What am I missing?

2
  • There is no init handler in component code. <aura:handler name="init" value="{!this}" action="{!c.init}"/> Nov 19 '20 at 1:27
  • wow, I totally missed that, you can post it as an answer please.
    – AjFmO
    Nov 19 '20 at 2:41
5
+50

There is no init handler in the component code.

<aura:handler name="init" value="{!this}" action="{!c.init}"/>
0

Have you ensured that the site guest user for your community endpoint has the right permissions to run the flow? There might be no errors starting the Lightning-out container but the guest user may be running into an issue accessing the flow. More details about site guest users and flow access can be found here.

You could probably test this by adding the flow into a publically accessible community and accessing it as the site guest user. I believe the guest user would still need the "Run Flow" permission even if the flow lives in a Salesforce community.

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.