1

I am trying to override the standard "edit" button in lightning with a custom model.

However I'm getting an error when using force:recordEdit.

The error screenshots are as follows enter image description here

enter image description here

The issue is intermittent. I'm able to save the record two times in edit mode. On the third time, it throws this error. Below are the relevant parts of my code.

Component

<aura:attribute name="modelStyle" type="String" />
    <aura:attribute name="showModal" type="Boolean" default="FALSE"/>
    <aura:attribute name="stages" type="String[]" default="Any,Open,Closed,Closed Won"/>
    <aura:attribute name="addressObjects" type="Map" access="private" />
    <aura:attribute name="addressToSerach" type="String"/>
    <aura:attribute name="mappingNames" type="String[]" access="private"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="mappingName" type="String" />
    <aura:attribute name="mappingState" type="String" />
    <aura:handler name="lookupSelected" event="c:LookupSelected" action="{!c.handleEvent}"/>
    <aura:handler name="selectedLookupRemoved" event="c:selectedLookupRemoved" action="{!c.handleEvent}"/>
    <aura:attribute name="result" type="String"/>
    <aura:attribute name="uniqueId" type="String"/>
    <aura:attribute name="num" type="Integer"/>
    <aura:attribute name="lookupId" type="Id"/>
    <aura:attribute name="value" type="Object"/>
    <aura:attribute name="loadedRecord" type="Object"/>
    <aura:attribute name="loadedRecordFields" type="Object"/>
    <aura:attribute name="recordNotFound" type="String"/>
    <aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.hideModal}"/>
    <aura:method name="showPopup">
  </aura:method>
    <style>
        {!v.modelStyle}
    </style>
  <div class="slds-modal slds-fade-in-open slds-backdrop slds-backdrop--open" tabindex="-1">
    <div class="slds-modal__container">
       <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick="{!c.hideModal}">
          <lightning:icon iconName="utility:close" alternativeText="Close" />
        </button>
        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Edit Record</h2>
      </header>
      <div class="slds-scrollable slds-modal__content slds-p-around--medium">
        <div class="slds-clearfix forceDetailPanel">
        <force:recordEdit aura:id="editView" recordId="{!v.recordId}"/>

        <footer class="slds-modal__footer">
            <lightning:button variant="neutral" label="Cancel" onclick="{!c.hideModal}"/>
            <lightning:button variant="neutral" label="Save"   onclick="{!c.save}"/>
        </footer>
    </div>
</div>

Controller

({
  doInit : function(component, event, helper) {
        console.log('Inside init method');
    //var showmodal ='TRUE'; 
   component.set("v.modelStyle", ".forceStyle .viewport .oneHeader.slds-global-
    header_container {z-index:0}");
    component.set("v.showModal",'TRUE');
    var crAccounts = component.get("v.showModal");
    console.log(crAccounts);
    var recordId = component.get("v.recordId");
    console.log('Recordid--->'+recordId);
    helper.retrieveMappings(component);

    },

 hideModal : function(component, event, helper) {
     //Toggle CSS styles for hiding Modal
    console.log('Inside hideModal');
   component.set("v.showModal",'FALSE');
     var crAccounts = component.get("v.showModal");
  console.log(crAccounts);
  var recordId = component.get("v.recordId");
   var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
    "recordId": component.get("v.recordId"),
    "isredirect":true
    });
    navEvt.fire();
},

save : function(component, helper) {
console.log('Inside record Save');
//component.get("v.body").get("e.recordSave").fire();
 var editView= component.find("editView");
 console.log('Edit--->',editView);
 component.find("editView").get("e.recordSave").fire();
 console.log('Edit Event fired successfuly--->');
}
})
  • I have also tried dynamically creating the force:recordEdit using $A.createComponent on init . However, when referred using component.find in save method, its returning undefined – Vishnu J Menon Sep 16 '17 at 20:22
  • Capture handleSaveSuccess event and refresh the view. – brahmaji tammana Sep 19 '17 at 5:55
0

Sometimes this issue occur due to client side caching.

Error 2: Uncheck the 'Enable secure and persistent browser caching to improve performance' in Setup > Session Settings.

Hope it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.