How do I save many records at once by clicking the Save button? I am not able to make the controller "handleSubmit". Please help me?

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">
    <aura:attribute name="reloadForm" type="boolean" default="true" />
    <aura:attribute name="listCertification" type="List" default="[1]" />
    <lightning:card title="Add your certifications" class="formAddCertification">
        <lightning:messages />
        <div class="buttonFormAddCert">
            <lightning:buttonIcon iconName="utility:add" variant="brand" value="Add more certification" alternativeText="Add more certification" title="Add more certification" onclick="{!c.handlerAddCert}" />
        <aura:iteration items="{!v.listCertification}" var="item">
            <lightning:recordEditForm aura:id="{!'formAddCertification'+item}" objectApiName="Certification__c" >
                <div class="slds-size_6-of-6 slds-p-bottom-small">
                    <label >Developer</label>
                    <lightning:inputField aura:id="field" fieldName="Developer__c" variant="label-hidden"  required="true"/>
                <div class="demo-only demo-only--sizing slds-grid slds-wrap">
                    <div class="slds-size_4-of-6 slds-p-top--x-small">
                        <label >Certification</label>
                        <lightning:inputField aura:id="field" fieldName="Certification__c" variant="label-hidden"/>
                    <div class="slds-size_2-of-6 slds-p-top--x-small">
                        <label >Certification Date</label>
                        <lightning:inputField aura:id="field" fieldName="Certification_Date__c" variant="label-hidden"/>
        <div class="buttonForm">
            <lightning:button label="Cancel" onclick="{!c.handleReset}" />
            <lightning:button type="submit" variant="brand" label="Save" onclick="{!c.handleSubmit}"/>  
    handlerAddCert: function(component, event, helper) {
        var listCertification = component.get('v.listCertification');
        component.set('v.listCertification', listCertification);
    handleReset: function(component, event, helper) {
        component.find('field').forEach(function(f) {
    handleSubmit : function(component, event, helper) {
        var listCertification = component.find('v.listCertification');

1 Answer 1


aura:id cannot be an expression, it must be a literal value.


You can try to submit all the records at once:

  .forEach(function(form) {

However, this may not work well if there's a large number of records. It is strongly recommended that you use Apex to save multiple records quickly. See this answer for what you can expect with performance (it deals with loads, not saves, but the effect is similar).

  • After making the suggested change, I have the following error: " This page has an error. You might just need to refresh it. Action failed: c:AddCertification$controller$handleSubmit [Cannot read property 'forEach' of undefined] Failing descriptor: {c:AddCertification$controller$handleSubmit} " Could you help me again?
    – Juliana
    Aug 19, 2020 at 3:16
  • @Juliana make sure the aura:id matches the value used for component.find().
    – sfdcfox
    Aug 19, 2020 at 3:27
  • That was the cause of the error. Thank you.
    – Juliana
    Aug 19, 2020 at 3:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .