0

I have two individual LWC's on a record page. From one, I can create records that I the second separate LWC to update.

I am able to achieve a refresh for the LWC from which the changes are made. But on the second LWC there is no refresh until done at the browser level I just want the second LWC to make a backend call when returning to the record page so that the updated data shows correctly without a browser refresh

I've tried using refreshApex, the following works in the LWC that I'm creating from but I still need to update the second LWC.

lwc js:

_wiredMarketData;
@wire(getTasks, { RecordId: '$recordId' })
wiredAct(wireResult){
    const { data, error } = wireResult;
    this._wiredMarketData = wireResult;
    if(data){
        this.taskList = data
    }
    if(error) {
        console.error(error)
    }
}
-----------
    //onsuccess call
    handleTaskCreated(event) {
        //set the task id so we can update it with resources later
        this.taskId = event.detail.id;
            
        refreshApex(this._wiredMarketData);

        //update resources with mission task id
        this.updateResources();
        this.navigateTaskDetailsPage(event);

    }
2
  • 1
    You're using refreshApex incorrectly. Also, remember that this method is asynchronous, so you will want to wait on it (async handleTaskCreated(event) { /* snip */ await refreshApex(this.taskWire). I've linked an answer that should get you most of the way there.
    – sfdcfox
    Mar 10, 2023 at 20:26
  • Well, I figured it out. I used pubsub to call a method on the second LWC and then called refreshapex from that LWC to refresh.
    – mackmama
    Mar 11, 2023 at 15:55

0