1

Have have a button on a LWC, when clicked calls the following method:

handleSubmitForApproval() {
    console.log('Submit for Approval clicked.');
    submitForApproval({recordId : this._agreementId})
        .then(() => {
            console.log('Submit for Approval returned.');
            return refreshApex(this.getAccountResult);
        });
}

The submitForApproval server method just submits a record for approval. This works fine.I can also get the message Submit for Approval returned.. However, my 'getRecord' wire 'getAccountResult' is not being refreshed.

Why does refreshApex not execute when called imperatively?

1 Answer 1

2

It does get called. But the callback function related to this.getAccountResult is executed only if there is change in any of the fields of object in your client machine and database. So, if you have console logs, you will see the logs in this.getAccountResult callback function only if there is change in client record vs database record

3
  • Thanks for the answer. As the object returned from the wire is cached it is read-only. I thought the whole point of refreshApex is to force a refresh of your data, regardless if it has changed or not. Any suggestions on how I might force a refresh from the client-side? Jun 9, 2020 at 13:05
  • What it is doing is absolutely fine. Why do you want the function to run when there is absolutely no change? that leads to performance issues. For testing it, you can change some field value (which you are querying in getRecord) in database in developer console and immediately invoke refreshApex in UI and check Jun 9, 2020 at 16:15
  • I have a chain of events that sets up the UI based on server updates. I decided to just update the UI on the client side (simulate the refresh) as the result will be the same as a server or page refresh. I agree with your point about performance. Jun 9, 2020 at 20:27

You must log in to answer this question.

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