Newer Version Available
refreshTab() for Lightning Experience
Refreshes a workspace tab or a subtab specified by tabId. Keep in mind that the first subtab has the same tabId as the workspace tab. This method works only in
Lightning console apps.
If this method is invoked for a workspace tab with unsaved changes, a confirmation window
opens for the user.
- Continue editing: Changes are preserved and the tab or workspace isn’t refreshed.
- Discard changes: Changes are discarded and the tab or workspace is refreshed.
- Save: Changes are saved and then the tab or workspace is refreshed.
Arguments
| Name | Type | Description |
|---|---|---|
| tabId | string | ID of the workspace tab or subtab to refresh. |
| includeAllSubtabs | boolean | Optional. If the tabId corresponds to a workspace tab, all subtabs within that workspace are refreshed. The default is true. Keep in mind that the first subtab has the same tabId as the workspace tab. |
Sample Code
This component has a button that, when pressed, refreshes the focused workspace tab and all its open subtabs.
Component code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global">
2 <lightning:workspaceAPI aura:id="workspace"/>
3 <lightning:button label="Refresh Focused Tab" onclick="{!c.refreshFocusedTab}"/>
4</aura:component>Controller code:
1({
2 refreshFocusedTab : function(component, event, helper) {
3 var workspaceAPI = component.find("workspace");
4 workspaceAPI.getFocusedTabInfo().then(function(response) {
5 var focusedTabId = response.tabId;
6 workspaceAPI.refreshTab({
7 tabId: focusedTabId,
8 includeAllSubtabs: true
9 });
10 })
11 .catch(function(error) {
12 console.log(error);
13 });
14 }
15})Response
This method returns a promise that, upon success, resolves to true. If there was an error, the promise is rejected.