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
Dhilip DussaDhilip Dussa 

Close console sub tab

I need some help closing the sub-tab on Console view

I was created one button on the Account Record page. If I click on this button it will open a pdf file in a new sub-tab. in this sub-tab I have one cancel button if I click on this I need to close this sub tab. please help me.

Thanks,
Dilip Dussa.
PriyaPriya (Salesforce Developers) 

Hi Dhilip,

Kinldy refer to the below example to close the tab:- 
Aura component :- 
<aura:component implements="flexipage:availableForAllPageTypes" access="global"> <lightning:workspaceAPI aura:id="workspace"/> <lightning:button label="Close Focused Tab" onclick="{!c.closeFocusedTab}"/> </aura:component>

Controller.js:- 
closeFocusedTab : function(component, event, helper) { var workspaceAPI = component.find("workspace"); workspaceAPI.getFocusedTabInfo().then(function(response) { var focusedTabId = response.tabId; workspaceAPI.closeTab({tabId: focusedTabId}); }) .catch(function(error) { console.log(error); }); }

Please mark as Best Answer so that it can help others in the future.

Regards,

Priya Ranjan