Categories
lwc Salesforce

Launch custom LWC from Quick Action using Lightning Component

As of now, SFDC does not support Quick Action for LWC

Solutions always exists

Problem- Using Quick Action to launch custom Lightning web components.

Solution:- 

  • Create a Lightning component as a wrapper for Quick action, to launch in subTab by using Open SFDC interface.
({ 
    init: function(component) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            workspaceAPI.openSubtab({
                parentTabId: response.tabId,
                pageReference: {
                    "type": "standard__component",
                    "attributes": {
                        "componentName": "c__customLWC" //Name of custom LWC followed by c__
                    },
                     "state": {
                        "c__recordId": component.get("v.recordId") //record id of project, need it inside custom lwc
                		}   
                },
                 focus: true
            }).then(function(subtabId) {
                console.log("The new subtab ID is:" + subtabId);
            }).catch(function(error) {
                console.log("error");
            });
        });
    }

})
  • Create quick action, which points to this Lightning component
  • Inject the custom lightning web component, to be launched from lighting component
  • Add lightning action to Page layout

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *