0

How can the workspace API's "open tab" functionality be achieved with lightning web components? I've only seen this functionality described for aura components in the documentation.

2

Looks like official support for this is coming out soon, it was flagged for Summer 20 but I don't see support for it yet. https://help.salesforce.com/articleView?id=lex_roadmap.htm&type=5

In the mean time you can manually generate the URL needed to have LEX open the page in a subtab. Here is code for opening the new page for a custom object and passing in default field values.

    navTo(recId){

        let defaultValues = {
            'Parent__c' : recId
        }

        this.createObjInSubtab(defaultValues,'Custom_Obj__c');
    }

    createObjInSubtab(defaultValues,obj){

        let defaultValuesEncoded = encodeDefaultFieldValues(defaultValues);
        let subTabURL = '/lightning/o/'+obj+'/new?nooverride=1&count=2&defaultFieldValues=';
        subTabURL += defaultValuesEncoded+'&ws='+encodeURIComponent(window.location.pathname+'?count=1')+'';

        let temp = {
            type: 'standard__webPage',
            attributes: {
                url: subTabURL
            }
        };

        this[NavigationMixin.Navigate](temp);
    }

0

There isn't one yet that I'm aware of. The best option today is to wrap your LWC in an Aura component, and then communicate between the Aura/LWC component via Lightning Messages or other events/attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.