1

I have a requirement to validate a few fields before submitting the record. I have created an Aura component and calling the LWC code to do some validation.

enter image description here

Aura Cmp:

<aura:component implements="flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader, force:hasRecordId">
    Record ID: {!v.recordId}
    <c:submitButton recordId="{!v.recordId}" />
</aura:component>

Lightning code:

import { LightningElement, api } from 'lwc';

export default class SubmitButton extends LightningElement {
    @api recordId;

    connectedCallback()
    {
        alert('Record ID'+recordId);
    }
}

Output:

enter image description here

My issue is:

  1. I am not able to see the alert message which I have in LWC component
  2. I don't want to see this Aura component when Submit Button is clicked.

what is the mistake I did?

1 Answer 1

5

You are doing syntax error. Your alert should be

alert('Record ID'+this.recordId);

For second point you need to close quick action modal from LWC. So call event from LWC to aura component and then in Aura component close this modal.

<aura:component implements = "force:lightningQuickAction, force:hasRecordId" >
    <c:lwcQA recordId="{!v.recordId}" onclose="{!c.closeQA}"/>
</aura:component>
({
    closeQA : function(component, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }
})

You can find detail working reference here: Close Quick Action from Lightning Web Components

You must log in to answer this question.

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