+ Start a Discussion
Haseeb Ahmad 9Haseeb Ahmad 9 

An unhandled fault has occurred in this flow when calling from VF

Hello,

I am getting this error when calling lightning flow from a VF page. It s a screen flow and when I click on next I get this error.

Any thoughts? 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Haseeb,

You need to check if the values being passed are proper or where the flow is breaking to resolve it when an error occurs in a flow you would be getting a email regarding the details or while debugging you can check the values.

Please check the details by using debug the flow button if it works fine then you need to check the vf page that is calling the flow.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Haseeb Ahmad 9Haseeb Ahmad 9
Hi Anutej,

I have a problem with a post to chatter component because of that I am getting an error but once I remove it start to work but now once I input all values inflow and click next and finish, instead of redirecting back to the opportunity record page flow just restarts again. 

Can you please let me know where I need to make changes on this code so it redirects me back to the curret page. 
 
<apex:page controller="EngageDealSupportButtonClass" lightningstylesheets="true">
    <apex:param name="opportunityId" value="{!$CurrentPage.parameters.opportunityId}"/>
    <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:navigateToSObject");
                            urlEvent.setParams({
                                "recordId": outputVar.value,
                                "isredirect": "true"
                            });
                            urlEvent.fire();
                        }
                    }
                }
            };
            $Lightning.use("c:lightflowApp", function() {
                // Create the flow component and set the onstatuschange attribute
                $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
                                           "flowContainer",
                                           function (component) {
                                               // Set the input variables
                                               var inputVariables = [
                                                   {
                                                       name : 'opportunityId',
                                                       type : 'SObject',
                                                       value : component.get ("v.recordId")
                                                   }
                                               ];
                                               
                                               // Start an interview in the flowContainer div, and 
                                               // initializes the input variables.
                                               component.startFlow("pservicerequest", inputVariables);
                                           }
                                          );
            });
            </script>
        </body>
    </html>
</apex:page>

any thoughts? thank you.