function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul AlladaRahul Allada 

How to get Id of the created record when using .submit function

How do i get the record ID of the newly created record when i use 
this.template.querySelector('lightning-record-edit-form').submit() 
and store it in a variable?
AnudeepAnudeep (Salesforce Developers) 
You should try logging event.detail.id to get the record Id. See below example from this documentation
 
handleSubmit(event){
   event.preventDefault();       // stop the form from submitting
   const fields = event.detail.fields;
   fields.Street = '32 Prince Street';
   this.template.querySelector('lightning-record-edit-form').submit(fields);
}
handleSucess(event){
   const updatedRecord = event.detail.id;
   console.log('onsuccess: ', updatedRecord);
}
 
handleSuccess(event){
    const payload = event.detail;
    console.log(JSON.stringify(payload));
}

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!