0

I'm currently using lightning:navigation via an action in a flow (this flow overrides the "New" action on a custom object list view), so users can navigate to their newly created record.

What I'm finding though is that when this navigation fires, it opens the record in a new workspace tab. Ideally, we'd like this to happen within the same tab, otherwise we just have a tab open still asking if they'd like to create a record.

The thing to note is, we're using service console. When we run the same logic outside of a service console, it will load the new record in the same tab.

We use the following method in aura to navigate to the record we want:

navigateToRecord : function(component, navigationService) {
        var actionName = component.get("v.actionName");
        var recordId = component.get("v.recordId");
        var objectAPIName = component.get("v.objectApiName");

        var pageReference = {
            type: 'standard__recordPage',
            attributes: {
                actionName: actionName,
                recordId: recordId,
                objectAPIName: objectAPIName 
            }
        };        
        
        navigationService.navigate(pageReference);

    }

In the flow, we set actionName to "view", recordId to the new record we've just created, and the objectAPIName to the object name we're creating the record on.

This is showing that the tab has been created after the navigation service has fired, leaving the create new record flow still open in the previous tab: Salesforce Tabs

Is there anyway we can just keep navigation within the same tab?

1 Answer 1

0

You can get the open tab Id and id of the tab where you want it to be a subtab. Then you can use openSubtab method to open the tab under another tab.

a sample code from above link:-

({
    openTabWithSubtab : function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openTab({
            url: '/lightning/r/Account/001xx000003DI05AAG/view',
            focus: true
        }).then(function(response) {
            workspaceAPI.openSubtab({
                parentTabId: response,
                url: '/lightning/r/Contact/003xx000004Ts30AAC/view',
                focus: true
            });
        })
        .catch(function(error) {
            console.log(error);
        });
    }
})

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .