Newer Version Available
refreshTab() for Lightning Experience
- 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 example is the workspaceAPIRefreshTab component from the lwc-recipes repo.
To make your component available for use in a Lightning console app, specify the lightning__AppPage target in the component’s configuration file.
Aura Components Sample Code
This component has a button that, when pressed, refreshes the focused workspace tab and all its open subtabs.
Component code:
Controller code: