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
The method provides the same argument for both Aura Components and Lightning Web Components (LWC).
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.
LWC Sample Code
This component checks if it’s in a Lightning console app, returns information about the focused tab and refreshes it. When the getFocusedTabInfo() method resolves successfully, it returns the tabInfo object. The const { tabId } syntax destructures the tabInfo object and binds the tabInfo.tabId value on the tabId variable. refreshTab() uses this tabId value to refresh the tab and its subtabs.
This method returns a promise that, upon success, resolves to true. If there was an error, the promise is rejected.
true doesn’t necessarily mean that the refresh was successful. For example, if the tab has unsaved changes when this method was called, the user has a choice to save or discard their changes. The refresh is canceled depending on user’s choice.