0

Having issues getting the onSuccess Event to fire on my Lightning:recordEditForm. My submit button is outside of the Lightning:recordEditForm and that works perfectly but i'd like to have the onSuccess fire so i can get some of the entered fields and use them elsewhere

Relevent Component Code

<aura:if isTrue="{!v.boopolicyvalues}">
<lightning:recordEditForm recordId="{! v.policyrecordID}" 
                      objectApiName="Policies__c"

                      onsuccess="{!c.onSuccess}"
                      aura:id="PVeditForm">
    <lightning:messages />
     <div class="slds-grid slds-gutters slds-p-bottom_large">
        <div class="slds-col">
      <lightning:inputField fieldName="Premium_Amount_RV__c" />
     <lightning:inputField fieldName="Cash_Surrender_Value_RV__c" />
     <lightning:inputField fieldName="Gross_Death_Benefit_RV__c" />
     <lightning:inputField fieldName="Values_as_of_RV__c" />
        </div>
       <div class="slds-col">

       <lightning:inputField fieldName="Cost_Basis__c" />
       <lightning:input  name="NewFileName" label="New File Name (Edit if 
Needed)" value="{!v.FinalFileName}"/>
         </div>
       </div>      
</lightning:recordEditForm>
</aura:if>  

Relevent Controller Code

handleNavigate: function(cmp, event, helper) {
//Set the File Fields (ie. CSV or Cost Basis) of the changed fields here

    if(cmp.get('v.selectedValue') == 'Policy Values' || 
cmp.get('v.selectedValue') == 'Illustration') {
         cmp.find('PVeditForm').submit();
        var navigate = cmp.get("v.navigateFlow");
        navigate(event.getParam("action"));
    }
    if(cmp.get('v.selectedValue') == 'Annual Values') {
        cmp.find('AVeditForm').submit();
        var navigate = cmp.get("v.navigateFlow");
        navigate(event.getParam("action"));
    }
    if(cmp.get('v.selectedValue')== 'Cost Basis') {
        cmp.find('CBeditForm').submit();
        var navigate = cmp.get("v.navigateFlow");
        navigate(event.getParam("action"));
    }


},

onSuccess: function(cmp, event, helper) {
    console.log(5);
       var payload = event.getParams().response;
       console.log(payload);

    },

Shouldnt it fire if the record is sucessfully updated (which i have confirmed many times that it has been)

I need to have the button outside the record edit form as this is within a flow and i need to have the flow move to the next page as well.

And although probably not the effecient way to do so, was using the console.log(5) to confirm it doesn't fire at all

  • i have a workaround with an Aura Id on the input fields but still would like to figure out why onsuccess isnt firing – Bobbygllh Mar 29 at 13:58
  • can you rename your method from onSuccess to something else, such as !c.successful – glls Mar 29 at 14:09
  • it was actually !c.handleSuccess for a long time (on both the Lighting:REF and in the controller) and still didnt fire – Bobbygllh Mar 29 at 14:10
  • I don't think you can submit the form from a button outside the form itself. In that case the onsucess or any other function will not get called. I verified this with a quick test. How is your form submit implemented? – Jayant Das Mar 29 at 15:17
  • @JayantDas You fortunately can submit from a button outside the form itself. I used cmp.find('AURA.ID').submit(); to do so. My main issue is that the onsuccess attribute does not fire when using this method – Bobbygllh Mar 29 at 21:40

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.