1

I'm having issues saving my new record using the code below. I'm trying to override the standard "New" function with a custom lightning:recordEditForm on a modal interface. The modal opens fine and it displays the fields how I want them but it doesn't save! I've been at this for months and I finally gave up. Yes, I'm new at this. Any help would be TREMENDOUSLY appreciated!

NewNote.cmp

<aura:component implements="force:lightningQuickAction,flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride" access="global">
    
    <aura:attribute name="newNote" type="Object"/>
    <aura:attribute name="recordError" type="String" />
    <aura:attribute name="parentId" type="String" />
    <aura:attribute name="fields" type="String[]" default="['Name', 'Type__c', 'Topic__c', 'Note__c', 'Translation_Services_Used__c', 'Company_Used__c', 'Language__c', 'Start_Date_Time__c', 'End_Date_Time__c']" />
    <aura:attribute name="translationUsed" type="Boolean" />
    <aura:attribute name="isModalOpen" type="boolean" default="true"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <force:recordData aura:id="NewNote"
                      fields="Id, Name, Type__c, Topic__c, Note__c, Translation_Services_Used__c, Company_Used__c, Language__c, Start_Date_Time__c, End_Date_Time__c"
                      targetRecord="{!v.newnote}"
                      targetError="{!v.recordError}"
                      layoutType="FULL"
     />
    
    <lightning:recordEditForm aura:id="NewNote" 
                              objectApiName="Case_Notes__c"
                              onsuccess="{!c.handleSuccess}">
 
        <aura:if isTrue="{!v.isModalOpen}">
     
 <!--###### MODAL BOX Start######-->
 <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- ###### MODAL BOX HEADER Start ######-->
                    <header class="slds-modal__header">
                        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{!c.closeModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">New Note</h2>
                    </header>
                    <!--###### MODAL BOX BODY Part Start######-->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                            <lightning:inputField fieldName="Type__c" value = "Case Note" required="true" />
                            <lightning:inputField fieldName="Topic__c" required="true" />
                            <lightning:inputField fieldName="Note__c"/>
                            <lightning:inputField aura:id="chkbox" fieldName="Translation_Services_Used__c" onchange="{!c.onCheckBoxChange}"/>
                                <aura:if isTrue="{!v.translationUsed}">
                                    <lightning:inputField fieldName="Company_Used__c" />
                                    <lightning:inputField fieldName="Language__c" />
                                    <lightning:inputField fieldName="Start_Date_Time__c" />
                                    <lightning:inputField fieldName="End_Date_Time__c" />                                   
                                </aura:if>
                    </div>
                    <!--###### MODAL BOX FOOTER Part Start ######-->
                    <footer class="slds-modal__footer">
                        <lightning:button variant="brand"
                                          type="submit"
                                          name="save"
                                          label="Save"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>    
            <!--###### MODAL BOX Part END Here ######-->
    </aura:if>
</lightning:recordEditForm>    
</aura:component>

NewNoteController.js

({
    doInit: function(component, event, helper) {
      
    },
    
    closeModel: function(component, event, helper) {
        component.set("v.isModalOpen", false);

    },
    
    onCheckBoxChange : function(component, event, helper) {
        component.set("v.translationUsed", component.find("chkbox").get("v.value"));
    },
    
        
    handleSuccess : function(component, event, helper) {
        var contactRec = event.getParams().response;
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
           "recordId": contactRec.id,
           "slideDevName": "related"
       });
        
       navEvt.fire();
     },    
})
2
  • out of curiosity, any reason why you are not using LWC ?
    – glls
    Oct 7, 2021 at 19:48
  • also, what part of your code "isint working? is handleSuccess invoked? any debug logs?
    – glls
    Oct 7, 2021 at 19:49

0

You must log in to answer this question.