Skip to main content
added 198 characters in body
Source Link

Seems we were wrong... This code worked for me. The trick was to set true 'exposed' property in js-meta.xml

LWCContainerAction.cmp

<aura:component implements="force:LightningQuickAction, force:hasRecordId">
    <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
    {!v.body}
</aura:component>   

LWCContainerActionHelper.cmp

({
init : function(component) {
    const recordId = component.get('v.recordId');
    $A.createComponent(
        `c:lwcTest`, {recordId : recordId},
        function(lwcCmp, status, errorMessage) {
            if (status === "SUCCESS") {
                var body = component.get("v.body");
                body.push(lwcCmp);
                component.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.");
            }
            else if (status === "ERROR") {
                console.error("Error: " + errorMessage);
            }
        }
      );
}
})

lwcTest.html

<template>
    test success
</template>

lwcTest.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    **<isExposed>true</isExposed>**
</LightningComponentBundle>

enter image description here

I have developed Aura Component wrapper for LWC specific for Lighting Actions. So now you can call LWC from Lighting Action with additional benefits.

Repo: https://github.com/SAItm/LWCAction

Seems we were wrong... This code worked for me. The trick was to set true 'exposed' property in js-meta.xml

LWCContainerAction.cmp

<aura:component implements="force:LightningQuickAction, force:hasRecordId">
    <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
    {!v.body}
</aura:component>   

LWCContainerActionHelper.cmp

({
init : function(component) {
    const recordId = component.get('v.recordId');
    $A.createComponent(
        `c:lwcTest`, {recordId : recordId},
        function(lwcCmp, status, errorMessage) {
            if (status === "SUCCESS") {
                var body = component.get("v.body");
                body.push(lwcCmp);
                component.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.");
            }
            else if (status === "ERROR") {
                console.error("Error: " + errorMessage);
            }
        }
      );
}
})

lwcTest.html

<template>
    test success
</template>

lwcTest.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    **<isExposed>true</isExposed>**
</LightningComponentBundle>

enter image description here

Seems we were wrong... This code worked for me. The trick was to set true 'exposed' property in js-meta.xml

LWCContainerAction.cmp

<aura:component implements="force:LightningQuickAction, force:hasRecordId">
    <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
    {!v.body}
</aura:component>   

LWCContainerActionHelper.cmp

({
init : function(component) {
    const recordId = component.get('v.recordId');
    $A.createComponent(
        `c:lwcTest`, {recordId : recordId},
        function(lwcCmp, status, errorMessage) {
            if (status === "SUCCESS") {
                var body = component.get("v.body");
                body.push(lwcCmp);
                component.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.");
            }
            else if (status === "ERROR") {
                console.error("Error: " + errorMessage);
            }
        }
      );
}
})

lwcTest.html

<template>
    test success
</template>

lwcTest.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    **<isExposed>true</isExposed>**
</LightningComponentBundle>

enter image description here

I have developed Aura Component wrapper for LWC specific for Lighting Actions. So now you can call LWC from Lighting Action with additional benefits.

Repo: https://github.com/SAItm/LWCAction

Source Link

Seems we were wrong... This code worked for me. The trick was to set true 'exposed' property in js-meta.xml

LWCContainerAction.cmp

<aura:component implements="force:LightningQuickAction, force:hasRecordId">
    <aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
    {!v.body}
</aura:component>   

LWCContainerActionHelper.cmp

({
init : function(component) {
    const recordId = component.get('v.recordId');
    $A.createComponent(
        `c:lwcTest`, {recordId : recordId},
        function(lwcCmp, status, errorMessage) {
            if (status === "SUCCESS") {
                var body = component.get("v.body");
                body.push(lwcCmp);
                component.set("v.body", body);
            }
            else if (status === "INCOMPLETE") {
                console.log("No response from server or client is offline.");
            }
            else if (status === "ERROR") {
                console.error("Error: " + errorMessage);
            }
        }
      );
}
})

lwcTest.html

<template>
    test success
</template>

lwcTest.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    **<isExposed>true</isExposed>**
</LightningComponentBundle>

enter image description here