0

I am following the instructions here to have my flow inside my visualforce page render in lightning by embedding an aura component. I want to redirect the flow at finish to another visualforce page. This page mentions it's possible to redirect to another page but doesn't show me how for a VFpage. I made an output variable in my flow called "outputVar" and set the default value to "redirect". That didn't work. When I preview the VF page it goes through the flow, but doesn't redirect.

    <apex:page >
   <html>
      <head>
         <apex:includeLightning />
      </head>
      <body class="slds-scope">
         <div id="flowContainer" />
         <script>
                var statusChange = function (event) {   
               if(event.getParam("status") === "FINISHED") {    
                  // Control what happens when the interview finishes   
    
var outputVariables = event.getParam("outputVariables");
                    var outputVar;
                    for(var i = 0; i < outputVariables.length; i++) {
                        outputVar = outputVariables[i];
                        if(outputVar.name === "redirect") {
                            var urlEvent = $A.get("e.force:navigateToURL");
                            urlEvent.setParams({
                                "url": "/jrsl_ul_unsubscribefinish"
                            });
                            urlEvent.fire();
                        
                     }  
                  } 
               }    
            };

            $Lightning.use("c:campPrefCenterApp", function() {
               // Create the flow component and set the onstatuschange attribute
               $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
                  "flowContainer",
                  function (component) {
        
                     component.startFlow("jrsl_Unsubscribe_Link")
                  }
               );
            });
         </script>
      </body>
   </html>
</apex:page>

1 Answer 1

0

Given the URL that you're redirecting to on completing the flow looks static, you can simplify the function you're calling there significantly. The function you've used is is what I'd expect to see in an Aura component controller, but given it's the Visualforce page that is actually running this code, you can use something like the below:

var statusChange = function (event) {
    if(event.getParam("status") === "FINISHED") {
       // Control what happens when the interview finishes. In this case redirect to another Visualforce page called OtherVisualforce.
       window.location = '{!URLFOR($Page.OtherVisualforce)}';
    }
};
4
  • Thank you very much!! You solved it. Commented Jul 3, 2023 at 21:35
  • If it solved it for you, could you upvote/select that the answer solved it for you so that others know in the future :) Commented Jul 3, 2023 at 23:46
  • I don't have enough reputation to cast a vote :( Commented Jul 5, 2023 at 21:15
  • You should still be able to accept the answer which will serve the same purpose. Commented Jul 5, 2023 at 23:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .