5

I am trying the new summer 21 feature: LWC from quick action. I am trying this on my developer edition, already updated to summer 21 version.

But with a very simple code, the modal is not opening and I get and error that I don't understand.

Html:

<template> 
   Test quick action
</template>

js:

import { LightningElement, api } from 'lwc';
 
export default class TestQuickAction extends LightningElement {

    @api recordId;

    connectedCallback() {
        console.log("recordId", this.recordId);
    }
}

xml:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="urn:metadata.tooling.soap.sforce.com" fqn="testQuickAction">
  <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
            <actionType>Action</actionType>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

Console Error:

[LWC QUICK ACTION]s.invoke is not a function
handleClick @   executorLwcHeadless.js:1

Any Idea?

1 Answer 1

10

If you want to create the screen action then use action type as ScreenAction. Action can be used only for headless actions. For headless action, you need to define the @api invoke(){...} function in your component.

Just change the action type inside the target config from your component's meta XML.

<actionType>ScreenAction</actionType>
5
  • 4
    FYI - When i tried this it says "Cannot change the type of the existing Lightning Web Component action."
    – CodeMonger
    Commented Jun 29, 2021 at 18:59
  • @CodeMonger did you try removing the references of the components? Commented Jun 30, 2021 at 6:17
  • 4
    @CodeMonger I have it too. Deletion of component and re-creation worked
    – kurunve
    Commented Nov 28, 2021 at 18:40
  • 4
    Had to delete from org and redeploy from vscode.
    – Venkata
    Commented Apr 26, 2022 at 4:31
  • 1
    I had to delete the action AND the LWC, then redeploy the LWC to bypass the "cannot change..." error Commented Jun 29, 2023 at 16:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .