0

JS :

import { LightningElement, api } from 'lwc';

import { ShowToastEvent } from "lightning/platformShowToastEvent";

export default class DemoHeadlessQuickActionComponent extends LightningElement {

@api invoke() {
    this.dispatchEvent(
        new ShowToastEvent({
            title: "Headless Action",
            message: "You called the headless action!",
            variant: "success"
        })
    );
}
}

MetaXML :

    <?xml version="1.0" encoding="UTF-8"?>
    <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
            <actionType>Action</actionType>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

When I click the quick action from my case record page, I'm getting "[LWC QUICK ACTION]t.invoke is not a function" in my browser console. Can any one please let me know what am I missing here.

3
  • 1
    See if this one seems similar to solve your problem: salesforce.stackexchange.com/questions/347436/…
    – Night Guy
    Commented May 5, 2022 at 11:11
  • I used same code in my org and it is showing the toast message on click of quick action. May be earlier version of code had some issue and you have fixed it. Refresh and retry. Commented May 5, 2022 at 11:12
  • I'm not sure. But after logging out and tried after some time did the trick
    – sfdcOwl
    Commented May 9, 2022 at 5:09

0

You must log in to answer this question.

Browse other questions tagged .