1

In my opportunity record page I have added 2 different LWC component. componentA is updating the opportunity fields. componentB is displaying some messages based on the opportunity fields. These components are not child parent and displayed in the same page.

I want componentB to refresh and get the latest messages once the record is updated from componentA.

In componentB I am using wire to call the Apex method which gets all the messages.

@wire(getOpportunityMessages,{recordId: '$recordId'})
DisplayMessages;

In componentA I have tries calling updateRecord(recordInput, clientOptions) and getRecordNotifyChange(recordIds) after the opportunity field update but nothing is triggering the wire method in componentB again. In Aura this can be done using force refresh as it refreshes the complete record. How can we do this is LWC?

1 Answer 1

1

Two choices I can think of:

  1. Use the Lightning Message Service to communicate between LWC in different trees. (If I had to guess, this is probably the Salesforce recommended way)

  2. Create an Aura wrapper over component A, and fire an CustomEvent from component A, the wrapper listens for this event and fires force:RefreshView event. (This is easier to implement but I'm not sure if this will force the wire adapter of component B to rerun)

You must log in to answer this question.

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