0

Hi we have developed custom import and export functionality, but when i select some file to upload and went back to the opportunity and for the next when ever i am trying to click on the list button to call my component previously selected file is still on the component, it is not opening the fresh instance of the component. I tried with "$A.get('e.force:refreshView').fire();" in doinit block and in rederer but it is not working.

Can any one suggest how to refresh/reload the aura component every time when called from button.

Below is the Aura component UI : enter image description here

once i upload the file and uploaded the records, enter image description here

when i click on back and went to opportunity page and again tried to access the same component it is still showing the above page not the fresh component, i need to force refresh/ reload the URL in order to get the fresh component. How can i over come this issue.

1
  • Are you using URL addressable component? Jun 3, 2020 at 12:25

2 Answers 2

2

You can try below code

setTimeout(function(){ $A.get('e.force:refreshView').fire(); }, 3000);
2
  • 1
    This definitely will not work. Aura events are not fired when outside the Aura life cycle. A minimal change would be to wrap the function in $A.getCallback.
    – sfdcfox
    Jun 3, 2020 at 13:14
  • I tried both, but still it is not working. This my logic for back button : ({ navigateTo : function(cmp, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": "/" + cmp.get("v.recordId"), "isredirect" : true }); urlEvent.fire(); $A.getCallback(function(){ $A.get('e.force:refreshView').fire(); }, 3000); //setTimeout(function(){ $A.get('e.force:refreshView').fire(); }, 3000); },
    – Anitha
    Jun 3, 2020 at 13:51
0

You can try another workaround. This will work for you are requirment.

navigateTo : function(cmp, event, helper) { 
   window.setTimeout(function(){ $A.get('e.force:refreshView').fire(); }, 3000); 
   window.location.href = "/" + cmp.get("v.recordId"); }

You must log in to answer this question.

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