function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dippan PatelDippan Patel 

Close Previous tab in Console using javascript

Hi All, 

I am using visualforce page in lightning for creating a new record. In case of Lightning Console, the record gets saved and open up in a new tab, the current tab with the create record visualforce page remains as it is. 

Here is my sample code: 
<apex:commandButton action="{!customsave}" value="save"  onComplete = "testmethod();"> 

    //get the record Id (format: "/recordid");

How do I close the current tab before the new tab is open? I tried salesforce's console - closeTab() but it doesn't seem to be working. 

Thank you!
AnudeepAnudeep (Salesforce Developers) 
Can you try the following code?. I don't think there isn't any alternative to closeTab() other than window.close() javascript method
<apex:page sidebar="false" showHeader="false" > 
   <apex:includeScript value="/support/console/33.0/integration.js"/> 
   <script type="text/javascript">     
     //Close tab in Console    
        var callCloseTab= function callCloseTab(result) {
        function closeTab() {
//Close tab in Browser        
function closeWindow() {
       <flow:interview name="Log_an_Account_Call" buttonLocation="bottom" /> 
       <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>