[SalesForce] $A.get(‘e.force:refreshView’).fire() did not refresh the record detail component

I have created a lightning component for the lightning experience record pages. In the customize record page, I drag standard Record Detail component and my component to the page. In my component, I update some fields of a record. After I save those field, I fire up the e.force:refreshView event. But the standard record detail component did not refresh to show the new value of those field. Is there any way to force to refresh the standard record detail component?

Here's the code:-

Component:

<div>
<force:recordView recordId="{!v.recordId}"/>
</div>
<div>...some input field... <ui:button label="Save" press="{!c.save}"/> 
</div> 

Controller:

save : function(component) {
    var action = component.get("c.saveInput");
    action.setParams({
        "objectName" : component.get("v.sObjectName"),
        "recordId" : component.get("v.recordId"),
        "postcode": component.get("v.postcode"),
        "city": component.get("v.city"),
        "state": component.get("v.state"),
        "country": component.get("v.country"),
        "street": component.get("v.street")
    });
    action.setCallback(this, function(action) {
        $A.get('e.force:refreshView').fire();
    });
    $A.enqueueAction(action);
 }

Best Answer

You are not supposed to give same name to the apex controller's method and the function which is called on click. Also, you should pass event along with the component in the same. Please find the code below:-

Controller:-

save : function(component, event) {                
        var action = component.get("c.apexSave"); 
        action.setCallback(this, function(action) {                
           $A.get('e.force:refreshView').fire(); 
        }); 
        $A.enqueueAction(action); 
    }

Note save and apexSave.

The server-side action is also provided by the “c” value provider. This is the same value provider that provides the JavaScript controller event handler which handles the press event of the button and the init event. Because of this, you need to make sure that you do not name your Apex controller methods with the same name as your JavaScript controller methods. It’s easy to make the mistake of naming them same because it is natural to want to be consistent in naming.

Source:- Salesforce1 Lightning Components – Working with Controllers

You may use an aura handler to make sure that whether it has been refreshed successfully.

<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />