• Brock Irvine
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I am trying to set a redirect url for when a flow finishes. The flow I'm using is running off of a visualforce page. I tried writing this code, but it doesn't seem to be working. It's getting into the statusChange method, but it's not redirecting. I followed the documentation found here as closely as possible:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_lightningruntime.htm

Code:
 
<apex:page standardController="Account" extensions="Log_A_Call_Controller">
    <head>
        <apex:slds />
    </head>
         <apex:includeLightning />
         <body class="slds-scope">
         <div id="flowContainer" />
         <script>
         var statusChange = function(event){
                      if(event.getParam("status") === "FINISHED"){
                          console.log('Flow is finished. Attempting Redirect');
                          var urlEvent = $A.get("e.force:navigateToURL");
                          urlEvent.setParams({
                              "url": "/home"
                          });
                          urlEvent.fire();
                      }
                  }
            $Lightning.use("c:Log_A_Call_Flow", function() {
               $Lightning.createComponent("lightning:flow",
               {"onstatuschange":statusChange}, "flowContainer",
                  function (component) {
                     // Set the input variables
                     var inputVariables = [ {
                           name: 'recordId',
                           type: 'String',
                           value: "{!accountId}",
                        },
                        {
                           name: 'URL',
                           type: 'String',
                           value: "{!URL}"
                        }
                     ];
                     // Start an interview in the flowContainer div, and 
                     // initializes the input variables.
                     component.startFlow("Log_A_Call", inputVariables);
                  }
               );
            });
         </script>
         </body>
</apex:page>
What am I missing here?
I am trying to set a redirect url for when a flow finishes. The flow I'm using is running off of a visualforce page. I tried writing this code, but it doesn't seem to be working. It's getting into the statusChange method, but it's not redirecting. I followed the documentation found here as closely as possible:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_lightningruntime.htm

Code:
 
<apex:page standardController="Account" extensions="Log_A_Call_Controller">
    <head>
        <apex:slds />
    </head>
         <apex:includeLightning />
         <body class="slds-scope">
         <div id="flowContainer" />
         <script>
         var statusChange = function(event){
                      if(event.getParam("status") === "FINISHED"){
                          console.log('Flow is finished. Attempting Redirect');
                          var urlEvent = $A.get("e.force:navigateToURL");
                          urlEvent.setParams({
                              "url": "/home"
                          });
                          urlEvent.fire();
                      }
                  }
            $Lightning.use("c:Log_A_Call_Flow", function() {
               $Lightning.createComponent("lightning:flow",
               {"onstatuschange":statusChange}, "flowContainer",
                  function (component) {
                     // Set the input variables
                     var inputVariables = [ {
                           name: 'recordId',
                           type: 'String',
                           value: "{!accountId}",
                        },
                        {
                           name: 'URL',
                           type: 'String',
                           value: "{!URL}"
                        }
                     ];
                     // Start an interview in the flowContainer div, and 
                     // initializes the input variables.
                     component.startFlow("Log_A_Call", inputVariables);
                  }
               );
            });
         </script>
         </body>
</apex:page>
What am I missing here?