0

I have created a custom lightning component that overrides the standard edit button on opportunities. As of now I am just trying to get it to function like the standard edit functionality, but there will be additional functionality added later.

It seems to work normally until you click save. The expected behavior would be that the record saves and you are returned to the record detail page which reflects the updates that you made as part of your edits. The behavior that I am getting is that the record saves (confirmed by querying the database) and you are returned to the record detail page however, the changes made during the edit do not reflect in the detail page fields.

In order to see the changes in the UI you have to go back to the recently viewed opportunity list view and click on the record that you edited, and refresh it once it opens. It is worth noting that the changes to the record show on the list view, but I need it to show on the detail page.

I have included the code that makes up the lightning component

cmp:

   <aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride">
   <aura:attribute name="recordId" type="Id" />
   <aura:registerEvent name="saveSuccess" type="force:recordSaveSuccess"/>
   <aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.redirect}"/>

   <!--Start Edit Form-->    

   <div aura:id="editDialog" role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open">
      <div class="slds-modal__container">
         <div class="slds-modal__header">
            <h2 class="slds-text-heading--medium">Edit Opportunity</h2>
         </div>
         <div class="slds-modal__content slds-p-around--medium slds-grid slds-wrap ">
            <lightning:recordEditForm aura:id="form" recordId="{!v.recordId}" objectApiName="Opportunity">
               <force:recordEdit aura:id="edit" recordId="{!v.recordId}"/>
            </lightning:recordEditForm>
            <div style="text-align: center;">
            </div>
         </div>
         <div class="slds-modal__footer">
            <lightning:button label="Cancel" onclick="{!c.redirect}"/>
            <lightning:button variant="brand" label="Save" onclick="{!c.save}" />
         </div>
      </div>
   </div>
   <div aura:id="overlay" class="slds-backdrop slds-backdrop--open"></div>

   <!--End Edit Form-->

</aura:component>

Controller.js

({
    save : function(component, event, helper) {
        component.find("edit").get("e.recordSave").fire();
},
    redirect: function(component, event, helper) {
        var recordId = component.get("v.recordId");
        helper.navigateTo(component, recordId, helper.refresh(recordId));
}
})

Helper.js

({
    navigateTo: function(component, recId, callback) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": recId
        });
        navEvt.fire();
        callback();
    },
    refresh:function(recId){
        var d = new Date();
    location.assign("/"+ recId+ "?nooverride=0&v="+ d.getTime()); 
    console.log("Callback");
    }
})

1 Answer 1

0

Update:

I was able to get this working.

Here are the steps I took:

  1. Navigate to setup
  2. Open 'Session Settings'
  3. Uncheck 'Enable secure and persistent browser caching to improve performance'
  4. Save

You must log in to answer this question.

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