+ Start a Discussion
louisa barrett 7louisa barrett 7 

flow from VF page being called twice

I have a VF page which uses a lightning component to call a flow(checks and decisions are made in the flow to determine if the asset should be deleted) to delete an asset. Depending on whether the user is in Classic or a console view the behaviour should be different. I use an identical page to delete a case rather than an asset and it works perfectly.
However when the asset is deleted. the flow appears to be called again. I'm getting the following error via email
Flow Details
Flow API Name: Delete_Asset
Type: Screen Flow
Version: 1
Status: Active
Org: CRB Cunninghams (00Db0000000eIN5)
Flow Interview Details
Interview Label: Delete Asset 18/03/2019 10:27
Current User: Louisa Barrett (005b0000003IbLU)
Start time: 18/03/2019 10:27
Duration: 0 seconds
How the Interview Started
Louisa Barrett (005b0000003IbLU) started the flow interview.
Some of this flow's variables were set when the interview started.
AssetID = 02i0J00000XVygLQAT
Find all Asset records where:
Id Equals {!AssetID} (02i0J00000XVygLQAT)
Assign those records to {!Asset}.
Save these field values in the variable: Id, Name, Added_to_Service_Contract__c, Service_Contract__c, Service_Contract_Status__c, Service_Contract_Start_Date__c, Service_Contract_End_Date__c, AccountId
Failed to find records.
Salesforce Error ID: 624516304-414064 (-1789764336)

This is my VF page that calls the flow
<apex:page standardController="Asset" lightningStylesheets="true" >
<!-- Orignal method to call flow -->
<!--<flow:interview name="Delete_Asset"


<apex:param name="AssetID" value="{!Asset.Id}"/>

  <apex:includeScript value="/support/console/40.0/integration.js"/>
            <apex:includeLightning />
        <body class="slds-scope">
            <div id="flowContainer" />
            <script type="text/javascript">
            var returnID = "{!Asset.Account.Id}";
            var statusChange = function (event) 
                console.log('Status change = ' + event.getParam("status"));
                if(event.getParam("status") === "FINISHED") 
                    // Use my return Id to open a tab
                    if (sforce.console.isInConsole())
                        window.parent.location = '/' + returnID; 
            ("c:TestLightningApp2", function()
                 // Create the flow component 
                 console.log('function called');
                                            function (component) 
                                                // Set my input variables
                                                var inputVariables =
                                                            name : 'AssetID',
                                                            type : 'String',
                                                            value : '{!Asset.Id}'
                                                // Start the flow and pass in the input variables
                                                component.startFlow("Delete_Asset", inputVariables);
            var closeSubtab = function closeSubtab(result)
                var tabId = result.id;
            var refreshPrimaryTab = function getTabId(result)
                var tabId = result.id;
                sforce.console.refreshPrimaryTabById(tabId, true);

If I use the original method to call the flow(commented text at the top of the page' it works fine.

Any help would be much appreciated