Piotr Czubek
Piotr Czubek

Reputation: 3

Salesforce lightning out

I am trying to use Salesforce component from external page. I proceed this manual: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/lightning_out_public_apps.htm but still have errors and nothing rendered. I have 404 for inline.js and bootstrap.css.

My code:

<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>LIG Boilerplate</title>
     <script src="https://custom-salesforce-domain/externalApps/lightning/lightning.out.js"></script>
     <script>

    let inputVariables = [];
    $Lightning.use("c:SGMVAOutside", function() {
        $Lightning.createComponent("lightning:flow", {},
            "container",
            function (component) {
                component.startFlow("SG_MVA_Triage_Flow_Lightning_Out", inputVariables);
            })
        ;},
        'https://custom-salesforce-domain/externalApps'
    );

</script>
</head>
 <body>
    <p>It works !!!</p>
     <div id='container'>

     </div>

 </body>
 </html>

Community is created. Community is public. Comunity has access to app.

What can be a problem source?

Upvotes: 0

Views: 1208

Answers (2)

Dane
Dane

Reputation: 3

An important know issue is that if you are using guest user access and you are also logged on to your experience community, you will get 404s for bootstrap and inline.js. https://issues.salesforce.com/issue/a028c00000qQ2LVAA0/lightning-out-app-implementing-ltngallowguestaccess-fails-to-load-inlinejs-and-bootstrapjs-when-the-customer-is-logged-into-his-community-app

Upvotes: 0

SF Jedi
SF Jedi

Reputation: 16

Try the following:

First and foremost, You to need implement a mechanism to fire the script on page load. Use the following,

<script>
function init(){
    let inputVariables = [];
    $Lightning.use("c:SGMVAOutside", function() {
        $Lightning.createComponent("lightning:flow", {},
            "container",
            function (component) {
                component.startFlow("SG_MVA_Triage_Flow_Lightning_Out", inputVariables);
            })
        ;},
        'https://custom-salesforce-domain/externalApps'
    );
}
</script>
</head>
 <body onload="init()">
    <p>It works !!!</p>
     <div id='container'>

     </div>

 </body>

For line #8, verify that you're using the correct domain format, see examples below.

FOR SANDOXES USE:
<script src="https://[custom-salesforce-domain-without-instance-number].lightning.force.com/lightning/lightning.out.js">

I.E.
<script src="https://FictiousCompany--SandboxName.lightning.force.com/lightning/lightning.out.js">

FOR PRODUCTION USE:
<script src="https://login.salesforce.com/lightning/lightning.out.js">

Line #17(Excluding blank lines), verify that you're using the correct format, see examples below.

FOR SANDOXES & PRODUCTION USE: 'https://[custom-salesforce-domain-with-instance-info]/[CommunityName]', [If applicable, AuthToken]);

I.E. Without AuthToken
'https://Domain.cs59.force.com/DemoCommunity', );

I.E. With AuthToken
'https://Domain.cs59.force.com/DemoCommunity', 12345789ABCDEF );

I hope this helps!

Upvotes: 0

Related Questions