+ Start a Discussion
Anupama@28Anupama@28 

$A.get('e.force:refreshView').fire(); not refreshing the record page

Hi,

I have a lighting component to delete the related list (child objects) records. after deleting the child records the parent view page is not getting refreshed i.e. the related list record count is not setting to 0 after deleting all of them. When I manually refresh the tab the related list's record count is updating. please help me in fixing this issue.
or how to delay the refresh ?

below is my code...
var action = component.get("c.clearRS");   //calling server-side method
        action.setParams({
        	"lstSelectedPL":selectedRecords
    	});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === 'SUCCESS'){
                helper.doInitHelper(component, event);
                $A.get('e.force:refreshView').fire();
            }
            ...
            ...
            ...


 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Anupama,

Greetings to you!

Try like this:
deleteChild : function(component,event,helper) {
        var action = component.get("c.clearRS");   //calling server-side method
        action.setParams({
        	"lstSelectedPL":selectedRecords
    	});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === 'SUCCESS'){
                helper.doInitHelper(component, event);
                $A.get('e.force:refreshView').fire();
            }
            ...
            ...
            ...
        )};
        $A.enqueueAction(action);
},

/*page refresh after data save*/
    
    isRefreshed: function(component, event, helper) {
        location.reload();
    },

And don't forget to add below handler in your component:
<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />

Also, please make sure to turn off browser caching in your Org.

From Setup, locate the link to ‘Session Settings
Locate the ‘Caching’ section
Uncheck the option to ‘Enable secure and persistent browser caching to improve performance

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Anupama@28Anupama@28
Hi Khan Anas,
Thanks for the reply.
It worked today automatically without much changes.
Seems like it was something with cache problem, Parent record page was perfectly refreshing when we delete the newly created child records.
but refresh was not happening only when we delete old/existing record.
However, I have just shifted the deleteChild method from component controller to helper.

Thanks,
Anupama