0

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?

1 Answers1

0

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!

SF Jedi
  • 16
  • 1