Is it possible to bulk insert a records using recordEditForm component?.

Here's the sample lightning component which I tried:

<lightning:recordEditForm aura:id="editFormAccount"  objectApiName="Account">       
            <table class="slds-table slds-table_bordered slds-table_col-bordered" style="min-width: 100px;">
                <thead >                            
                    <tr class="slds-no-hover">
                        <th>Account Name</th>
                        <td><lightning:inputField fieldName="Name"/></td>
                        <td><lightning:inputField fieldName="Name"/></td>
                        <td><lightning:inputField fieldName="Name"/></td>
            <lightning:button aura:id="submit" type="submit" label="Save" class="slds-m-top_medium" />

The above component is inserting only the last record. Then I read somewhere that we could actually make use of submit method in recordEditForm. Then added onsubmit event in recordEditForm and added a controller method to that. Here is the line I tried in controller:

handleSubmit: function(component, event, helper) {    

but the result which I got is same. It is inserting only the last record not all the 3 records. Is there any workaround?. I have a usecase where I need to bring Lookup styling, that is why am using recordEditForm.


Tried the solution provided by @sfdcfox


<aura:component implements="force:appHostable,lightning:actionOverride,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">
<aura:iteration items="1,2,3" var="iterate">
    <lightning:recordEditForm aura:id="editForm" objectApiName="Account">
        <lightning:inputField fieldName="Name"/>
<lightning:button aura:id="submit" onclick="{!c.handleSubmit}" label="Save" class="slds-m-top_medium" />


handleSubmit: function(component, event, helper) {
    alert('submit firing');
    component.find("editForm").forEach(form => form.saveRecord(
        result => {
            // Figure out what happened

Getting below error

Action failed: c:AccountNewPage$controller$handleSubmit [form.saveRecord is not a function] Failing descriptor: {c:AccountNewPage$controller$handleSubmit}

  • if i understand correctly, in your form, you are trying to create 3 accounts after entering only the name for each? Not sure this would be the best use case for the lightning:recordEditForm. Instead, why not have the user create 3 accounts separately?
    – glls
    Jul 25 '18 at 17:04
  • The actual use case is, I need to build a page where I should show 3 rows initially to enter child items for the parent. Very similar to MultiLine insert/update. Jul 25 '18 at 17:20
  • @mohammedazarudeen I ran into the same problem. only the last record is getting saved out of bulk. Were you able to solve this? May 21 '20 at 11:12

Your Answer

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

Browse other questions tagged or ask your own question.