Lightning Component

<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" />

I tried to create multiple accounts by using above code, by adding rows dynamically. for ex. In Row.1 I filled every fields , In Row.2 I left one field to fill i.e required.

The issues is when I tried to Submit both records, It's giving me the standard error on Row.2 "Please fill the require field", but Row.1 record Got created.

When I fill the required field on Row.2 and again click on Submit, then again Row.1 and Row.2 records got created.

So it become 3 records, so need to validate both records before submit by providing the standard error on field.

This is Controller I used.

handleSubmit: function(component, event, helper) {    

I am new salesforce lightning component, Any help would be appreciated.

1 Answer 1


you should validate each form before submit by validation logic. fire your standard validation message by error toast event if your validation fails. here is validation logic. you can use required attribute for your inputfield in lightning recordform too


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:availableForFlowScreens,lightning:actionOverride"
<aura:iteration items="1,2,3" var="iterate">
    <lightning:recordEditForm aura:id="editForm" objectApiName="Account">         
        <lightning:inputField aura:id="NameField" fieldName="Name"/>


handleSubmit : function(component, event, helper) {
        component.find("editForm").forEach( form =>{
           helper.showerrorToast(component);  // fire your toast Error message  here 



validateform: function(component) {
     var reqfelds = [].concat(component.find('NameField'))
     for(var i=0;i<reqfelds.length;i++){
             return false;
     return true;
showerrorToast : function(component) {
var toastEvent = $A.get("e.force:showToast");
    "title": "Required Field Error!",
    "type": "error"
    "message": "add your standard error message."


  • Thank you for your quick response. It Works . just have one issue. When I tried to hit submit after multiple records it is giving me the error. $controller$save [component.find(...).setError is not a function] to set the Standard error message. do we need to iterate this line. component.find('standerrorMessage').setError('set your standardmessage'); May 25, 2020 at 9:19
  • updated my answer, if it works for you please upvote the answer to help other community members
    – sdandamud1
    May 25, 2020 at 15:11
  • It works, Thank you very much. May 25, 2020 at 15:36
  • Can we show this error message near row or input field based on multiple field validation? May 25, 2020 at 17:01
  • Hi , Can we show this error message near row? May 27, 2020 at 7:53

You must log in to answer this question.

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