0

I have an Aura component that has a lightning:recordEditForm. In that form is a lightning:button. When clicking the button it should update the record but it is not. Here is the Aura component. Any ideas why it won't update the record?

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,force:hasRecordId">

    
    <aura:handler event="c:OfferAiRefreshEvent" action="{!c.refreshData}" />

    <aura:attribute name="recordId" type="String" />

    
    <lightning:recordEditForm 
        recordId="{!v.recordId}" 
        objectApiName="LLC_BI__Loan__c" 
    >
        <lightning:messages />
        <div class="slds-grid slds-wrap borderBottom">
            <lightning:outputField 
                class="borderBottom" 
                fieldName="Risk_Tier__c" 
                style="display: none;"
            />
            <lightning:outputField 
                class="borderBottom" 
                fieldName="LLC_BI__Payment_Type__c" 
                style="display: none;"
            />
            <lightning:inputField 
                class="borderBottom" 
                fieldName="RecordTypeId" 
                readonly="false"
                disabled="false"
            />
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:inputField 
                    class="borderBottom" 
                    fieldName="MCA_Agreements_ACH__c" 
                    readonly="false"
                    disabled="false"
                />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight buttonDiv">
                <lightning:button 
                    type="submit" 
                    name="update" 
                    label="Update" 
                />
            </div>
        </div>
    </lightning:recordEditForm>
    <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="LLC_BI__Loan__c" >
        <div class="slds-grid slds-wrap">
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="Early_Repay_Term__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Payment_Type__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Term_Months__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="SellRate__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Amount__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="Commission__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="TotalRepaymentAmount__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="Origination_Fee__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="Eligible_Concurrent_Funding_Amount__c" />
            </div>
        </div>            
    </lightning:recordViewForm>
        


</aura:component>

1 Answer 1

0

I am not sure why the default wouldn't work but adding in a custom handler did the trick, here is what I did for anyone that needs it.

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,force:hasRecordId">

    
    <aura:handler event="c:OfferAiRefreshEvent" action="{!c.refreshData}" />

    <aura:attribute name="recordId" type="String" />

    <div id="spinner" role="status" class="slds-spinner slds-spinner_medium slds-hide" style="top: 860px;">
        <span class="slds-assistive-text">Saving</span>
        <div class="slds-spinner__dot-a"></div>
        <div class="slds-spinner__dot-b"></div>
    </div>
    
    <lightning:recordEditForm 
        recordId="{!v.recordId}" 
        objectApiName="LLC_BI__Loan__c" 
        onsubmit="{!c.handleSubmit}"
        onsuccess="{!c.handleSuccess}"
        aura:id="mcaform"
    >
        <lightning:messages />
        <div class="slds-grid slds-wrap borderBottom">
            <lightning:outputField 
                class="borderBottom" 
                fieldName="Risk_Tier__c" 
                style="display: none;"
            />
            <lightning:outputField 
                class="borderBottom" 
                fieldName="LLC_BI__Payment_Type__c" 
                style="display: none;"
            />
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:inputField 
                    class="borderBottom" 
                    fieldName="MCA_Agreements_ACH__c" 
                    readonly="false"
                    disabled="false"
                    aura:id="mcaField"
                />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight buttonDiv">
                <lightning:button 
                    type="submit" 
                    name="update" 
                    label="Update" 
                />
            </div>
        </div>
    </lightning:recordEditForm>
    <lightning:recordViewForm recordId="{!v.recordId}" objectApiName="LLC_BI__Loan__c" >
        <div class="slds-grid slds-wrap">
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="Early_Repay_Term__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Payment_Type__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Term_Months__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="SellRate__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="LLC_BI__Amount__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="Commission__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="TotalRepaymentAmount__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingRight">
                <lightning:outputField class="borderBottom" fieldName="Origination_Fee__c" />
            </div>
            <div class="slds-col slds-size_1-of-2 paddingLeft">
                <lightning:outputField class="borderBottom" fieldName="Eligible_Concurrent_Funding_Amount__c" />
            </div>
        </div>            
    </lightning:recordViewForm>
        


</aura:component>
({
    refreshData: function (cmp, event, helper) {
        $A.get('e.force:refreshView').fire();
    },

    handleSubmit: function (cmp, event, helper) {
        event.preventDefault();
        document.getElementById("spinner").classList.remove("slds-hide");
        var mcaField = cmp.find("mcaField").get("v.value");
        var fields = event.getParam('fields');
        fields["MCA_Agreements_ACH__c"] = mcaField;
        cmp.find("mcaform").submit(fields);
    },

    handleSuccess: function (cmp, event, helper) {
        document.getElementById("spinner").classList.add("slds-hide");
    },

})

You must log in to answer this question.

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