<aura:iteration items="{!v.oppStageList}" var="opp"><lightning:recordEditForm aura:id = "StageChange" recordId ="{!opp.Id}" objectApiName ="Opportunity" onsuccess ="{!c.handleSuccess}" onsubmit="{!c.handleSubmit}">

                        <lightning:messages />
                        <lightning:layout multipleRows="true">
                            <lightning:layoutItem padding="around-medium" size="1">
                                <lightning:outputField aura:id="Owner" fieldName="OwnerId" variant="label-hidden"/>
                            <lightning:layoutItem padding="around-medium" size="1">
                                <lightning:outputField aura:id="Name" fieldName="Name" variant="label-hidden"/>

                            <lightning:inputField aura:id="approved" fieldName="Stage_Approved__c" variant="label-hidden" class="HideFields"/>
                            <lightning:layoutItem padding="around-small" size="2">
                                    <lightning:button disabled="{!v.disabled}" variant="success" name="save" label="Approve" type="submit" class="slds-m-right_x-small"/>
                                    <lightning:button disabled="{!v.disabled}" variant="destructive" type="submit" name="save" label="Reject" />

JS controller:

handleSubmit: function(component, event, helper) {
    //event.preventDefault(); // stop form submission
    var eventFields = event.getParam('fields');
    eventFields["Stage_Approved__c"] = true;
    component.find("StageChange").forEach( form =>{
    component.set('v.showSpinner', true);

handleSuccess: function(component, event, helper) {
    component.set('v.showSpinner', false);
  • which single record you want to submit? like if u have 10 items in v.oppStageList attribute which one you want to submit?
    – sdandamud1
    Commented Oct 3, 2019 at 18:27
  • @sdandamud1: it can be any record based on the save action out of 10. So how will I identify which one to save? The one in the JS controller where I am using forEach saves all the records if I clicked on any of the save action on any of the record. Commented Oct 4, 2019 at 0:56

1 Answer 1


In your controller markup, I am running for-loop on component.find("StageChange") and break it after one iteration. event.getParam('fields'); returns the row where the button has been pressed. You don't need to submit everything in component.find("StageChange") list.

handleSubmit: function(component, event, helper) {
    var eventfields= event.getParam('fields');
    for(var key in component.find("StageChange")){
  • I am getting eventFields["Id"] and event.getSource().get("v.name") bopth as 'undefined' Commented Oct 4, 2019 at 10:21
  • @hardikace29 please find the updated code. Commented Oct 4, 2019 at 15:58
  • how do I use selectedrecordid in handleSubmit? @sanket kumar Commented Oct 6, 2019 at 5:34
  • @hardikace29 I have updated the code. You don't need the aura:attribute at all. Commented Oct 8, 2019 at 11:12
  • thanks! That worked @Sanket Commented Oct 10, 2019 at 4:54

You must log in to answer this question.

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