I have a lightning data table and have added an action to "clone" the selected record. I'm unsure of how to go about copying fields from the selected record and creating a new record.

I was using a lightning-record-edit-form without the id. I'm just unsure of how I go about this. I tried this in the action but it does not set the group number field.

 // From Row Action Dropdown - Edit record
  cloneCurrentRecord(currentRow) {
    // open modal box
    this.bShowModal = true;
    this.isEditForm = false;
    this.isReadForm = false;
    this.isCloneForm = true;

    // assign record id to the record edit form
    this.currentRecordId = currentRow.Id;
    this.Group_Number__c = currentRow.Group_Number__c;

Any help would be greatly appreciated! thanks!



I figured it out as soon as I posted this. I need to create a variable to hold each field value in the method. For example, mygroupnumber. In the field under the form, I set the value... value={mygroupnumber}

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.