0

I'm trying to refresh LWC Component from AURA component. I need help in resolving the below error as i'm not able to figure out the issue here. Error :- Uncaught Action failed: c:QuoteLineItemsAuraComponent$controller$closeModelAddProduct [Cannot read property 'forceRefreshInitiated' of undefined]

Aura Component Code is as follows :-

<c:addProductsParentComponent style="padding:0px" recordId="{!v.recordId}" oncancelAndClose="{!c.closeModelAddProduct}">
        </c:addProductsParentComponent>

 <c:quoteLineItemRelatedList aura:id="messageBroker" style="padding:0px" recordId="{!v.recordId}"  oncancelAndClose="{!c.closeWindow}">
    </c:quoteLineItemRelatedList>

Aura JS Controller code is as follows :-

  closeModelAddProduct: function(component, event, helper) {
  // for Hide/Close Model,set the "openAddProductModal" attribute to "Fasle"
  component.find("messageBroker").forceRefreshInitiated();
     // refresh the view
    //$A.get('e.force:refreshView').fire();
  component.set("v.openAddProductModal", false);
  component.set("v.showButtonDiv", true);

},

LWC JS code is as follows :-

 @api
 forceRefreshInitiated() {
    console.log('forceRefreshInitiated');
    refreshApex(this.refreshTable);
  }

TIA, Sunil

3
  • No that dint help me to resolve my issue.
    – Sunil
    Commented Apr 1, 2020 at 7:54
  • 1
    I think it does...You should be able to call as the answer mentions for this exact scenario component.find("NameOfYourLWC").forceRefreshInitiated(); Commented Apr 1, 2020 at 11:39
  • My code is correct..but still i'm getting the error, that is the problem :) . Is there a need to declare :- <aura:handler event="force:refreshView" action="{! c.handleForceRefreshViewForLWC }"/> ..? I haven't declared this.
    – Sunil
    Commented Apr 1, 2020 at 14:40

0