I'm creating a record in lightning record-edit -form then in the handle success of my parent component i'm calling a child component to edit some fields of that record and passing the recordId of the first parent component to edit that record , but it's creating two records not editing the parent record rather it creates a new record with child component values.

in the handleSubmit1 of my child component i'm getting recordId as undefined but in handlesuccess of child component , recordid is present .

i'm passing the recordId from parent to child @api but still not sure , why it's not editing the Parent component record record.

HTML of parent component
<c-acess-form record-id={recordId}></c-acess-formm>
<lightning-button class="slds-m-top_small slds-float_right"  variant="brand" type="submit" label="submit" onclick={handleSubmit}> 

handle Success of parent component

    const event2 = new ShowToastEvent({
         title: 'Case Created',
         message: 'Case Created Successfully'+this.recordId,
     .forEach((el) => {

HTML of child component

<lightning-record-edit-form record-id={recordId} object-api-name ="Case" onsuccess={handleSuccess} onerror={handleError}>

Js of child component

 @api handleSubmit1(){


In the child component, do you have a @api recordId outside of all the functions? When you pass a property from parent to child (<c-acess-form record-id={recordId}></c-acess-formm>) You have to set a property in the child towards the top of the file named @api recordId

  • Yup , I have the @api recordId at child component . That’s why I find it strange that why it’s not updating the records
    – Soumi
    Jul 17 at 18:39
  • Remove the component from the page and readd it, sometimes when adding @api variables, you have to readd the component
    – Dylan Cadd
    Jul 17 at 18:52
  • I didn’t get it . Read it means ?
    – Soumi
    Jul 17 at 19:02
  • Re add it to the page
    – Dylan Cadd
    Jul 18 at 0:14
  • Yup tried that as well , didn't help . Seems like recordId for lightning-edit-form can be passed from putting the component in Recordlayout for editing , not passing that from a parent component .
    – Soumi
    Jul 18 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.