Newer Version Available
openTab() for Lightning Experience
Opens a new workspace tab. If the tab is already open, the tab is focused. This method works only in
Lightning console apps.
Arguments
| Name | Type | Description |
|---|---|---|
| pageReference | object | Specifies the pageReference to open. pageReference is optional. |
| recordId | ID | Specifies the record to open. recordId is optional. |
| url | URL |
The URL representing the content of the new workspace tab. url is optional. The URL can be either relative or absolute. To use a third-party domain, add the site as a CSP Trusted Site. |
| focus | boolean | Specifies whether the new tab has focus. To display the tab immediately, set focus to true. To open the tab in the background, set focus to false. |
| overrideNavRules | boolean | Optional. Specifies whether the open tab respects existing navigation rules. This argument has no effect on records that have no navigation rules configured and URLs that do not point to a record. |
Sample Code
This component has a button that when pressed, opens a tab.
Component code:
Controller code (pageReference):
Controller code (recordId):
Controller code (url):
Response
This method returns a promise that, upon success, resolves to the
tabId of the new tab.