Salesforce Interview Questions & Answers Book is now available!

Grab Now

LWC

Use LWC as Quick Actions - Spring '21

Before spring 21 update when we wanted to embed an LWC component as a quick action it was not that straightforward.

By Teja, ex-Salesforce engineer · Updated January 6, 2021 · 1 min read

Before spring 21 update when we wanted to embed an LWC component as a quick action, the route that we were taking is creating an Aura Application with necessary interfaces and embedding the LWC component in the Aura Component.

<aura:component implements="force:lightningQuickAction">	  
   <c:myLtngWebComponent></c:myLtngWebComponent>
</aura:component>

Then creating an object specific quick action by choosing the option as Lightning Component.

Starting this release, we can embed a LWC as a quick action, we don't have to wrap it up in an Aura Component.

We need to add the appropriate target to the xml and my hunch is it's going to be something like this

<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>49.0</apiVersion>
<isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__QuickAction</targets>
    </targets> 
</LightningComponentBundle>

Typical xml file for a web component

Then we need to create an object specific Quick Action and chose the target as Lighting Web Component.

This feature is pilot and you cannot spin up a pre-release org and test this out. You need to get in touch with salesforce support or you need to get in touch with AE.

I can see using this at a lot of places, considering the advantages that LWC has over Aura Components.

Learn it by building it

Every course, every code repository, the discussion group and certificates of completion — one subscription.

Keep me in the loop!

Email me when a new episode is published (promise, I will not spam you)

You're signing up to receive emails from Salesforce Casts