Need help finishing flow using ltng:outApp

Salesforce Asked by Merry Stambaugh on January 2, 2022

I am using the standard code provided by salesforce for the ltng:outApp. I need to have my flow close the window on finish for one flow, and navigate to the record created on another one.

I have read through a bunch of documentation, but I feel like all of the examples I find have the app created differently. I understand APEX and visualforce pretty well, but have never really created a lightning app.

<aura:application access="GLOBAL" extends="ltng:outApp" implements="ltng:allowGuestAccess">
<aura:dependency resource="lightning:flow"/>

Here is the visualforce

<apex:page >
     <apex:includeLightning />
  <body class="slds-scope">
     <div id="flowContainer" />
        var statusChange = function (event) {
           if(event.getParam("status") === "FINISHED") {
              // Control what happens when the interview finishes

        $Lightning.use("c:lightningOutApp", function() {
           // Create the flow component and set the onstatuschange attribute
           $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
              function (component) {

                 // Start an interview in the flowContainer div, and 
                 // initializes the input variables.

I have tried adding something similar to this to navigate to the created record, but I am not sure what needs to be set in my flow for this to work..

I cannot find anything that has worked to close the window when completed. In my old VF page I had it redirect to a page that was used javascript to close the window, but that does not see to work… or I am not redirecting correctly using navigateToUrl

   if(event.getParam("status") === "FINISHED") {
  var outputVariables = event.getParam("outputVariables");
  var outputVar;
  for(var i = 0; i < outputVariables.length; i++) {
     outputVar = outputVariables[i];
     if( === "redirect") {
        var urlEvent = $A.get("e.force:navigateToSObject");
           "recordId": outputVar.value,
           "isredirect": "true"


One Answer

If you go to the force:navigateToURL documentation

In the last line it says "This event is handled by the container. It’s supported in Lightning Experience, Salesforce app, and Lightning communities."

So force:navigateToURL will only work in container because there are listeners to respond to that event.

You can find this limitation mentioned in Lightning out considerations and Limitation section of Aura component developer guide.

Is visualforce page is really required in your case to call flow ? Where exactly you are trying to surface this vf page. I can think of a way of getting rid of visualforce page at all if its not necessary and directly calling the flow in lightning component. If that component is meant to be surfaced in salesforce lightning tab or lightning app builder or lightning record pages then I think navigateToURL event will work after flow finish.

Answered by SushantN on January 2, 2022

Add your own answers!

Related Questions

How to truncate a string to a specific length if it is longer?

4  Asked on February 10, 2021 by imajmdf


Update contact activity in Journey builder

1  Asked on February 10, 2021 by mary-jon


Hide iframe url

1  Asked on February 8, 2021 by cloudy-ritz


How can we add placeholder for lightning:InputField?

1  Asked on February 6, 2021 by aakash-poudel


LWC OSS Build Command

1  Asked on February 3, 2021 by scott-morrison


%%_PreHeader%% Personalization String

1  Asked on February 2, 2021 by victorcorey


Marketing cloud new Transactional Messaging API

1  Asked on January 30, 2021 by martijn-e


Can’t send to a list in marketing cloud?

1  Asked on January 30, 2021 by 4kaudio


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP