• Satishbabu Anupoju 1
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi Everyone,
I am getting issue while doing this LWC challenge - 
Use Lightning Data Service to Work with Data

ErrorWe can’t find an event handler named 'handleSuccess'.

Code -
contactCreator.Js
import { LightningElement,api,track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
//import CONTACT_OBJECT from '@salesforce/schema/Contact';
//import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName';
//import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName';
//import EMAIL_FIELD from '@salesforce/schema/Contact.Email';


export default class ContactCreator extends LightningElement {
    @api recordId;
    @api objectApiName;
    @track fields = ['FirstName', 'LastName', 'Email'];

    handleSuccess(event){
        
        const toastEvent = new ShowToastEvent({
            title: "Contact created",
            message: "Record ID: " + event.detail.id,
            variant: "success"
        });
        this.dispatchEvent(toastEvent);
    }

}
contactCreator.html
<template>
    <lightning-card>
        <lightning-record-form
            object-api-name={objectApiName}
            fields={fields}
            record-id={recordId} 
            onsuccess={handleSuccess}>
        </lightning-record-form>
    </lightning-card>
</template>

Please help me what i am doing wrong here as i have declared handleSuccess event in the JS .

Thanks,