3

I have design a Visual Flow in Salesforce that I have embedded in a VF page.

<apex:page sidebar="false" showHeader="false" > <flow:interview name="Log_an_Account_Call" finishLocation="forceclose" /> </apex:page>

It opens in a new tab in the Console or in the Browser with a Custom List button on Cases.

{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} {!REQUIRESCRIPT("/support/console/28.0/integration.js")} var url = '/apex/LogAccountCall'; if (sforce.console.isInConsole()) { srcUp(url); } else { window.open(url,'_blank'); }

When the user click finish in the flow, I want the tab to close in the Console and in the Browser. I found the code to close in the Browser:

<apex:page showChat="false" showHeader="false" sidebar="false" applyBodyTag="false" applyHtmlTag="false">
<html>
    <head>
        <title>ESCAPE</title>
        <script>
            function closeWindow() {
                window.open('','_parent','');
                window.close();
            }
        </script>       
    </head>
    <body onload="closeWindow()">          
    </body>
</html>
</apex:page>

and could not figure it out how to integrate "sforce.console.closeTab".

Any help will be very much appreciated.

Sylvie

1

1 Answer 1

1

I ended up doing it separately to make it works.

   <apex:includeScript value="/support/console/33.0/integration.js"/> 
   <script type="text/javascript">     
//Close tab in Console    
        var callCloseTab= function callCloseTab(result) {
            sforce.console.closeTab(result.id);
        }        
        function closeTab() {
                    sforce.console.getEnclosingTabId(callCloseTab);
                            }
//Close tab in Browser        
function closeWindow() {
                window.open('','_parent','');
                window.close();
            }
    </script>     
       <flow:interview name="Log_an_Account_Call" buttonLocation="bottom" /> 
    <div align="center">   
       <button href="#" onClick="closeTab();return false">Close This Tab in the Finance Console</button> 
       <button href="#" onClick="closeWindow();return false">Close This Tab in your Browser</button>
   </div>    

 
1
  • using sforce.console.closeTab(result.id). When console.log the result.id, i'm obtaining undefined. How and why?
    – vanessen
    Aug 7, 2018 at 11:48

You must log in to answer this question.

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