In my LWC I have:


@wire(getSObjectsForTable, {stepId: '$stepId', objectApiName: '$objectName'})
    this.wiredResults = result;
        this.tableData = getTableData(result.data);
        this.tableColumns = getColumns(this.tableData);
    } else if(result.error){
        let toastEvent = new ShowToastEvent({
            title: 'Error',
            message: 'Error retrieving records: ' + result.error,
            variant: 'error'
    this.tableLoaded = true;

I have a save and cancel button that fires events where I want to do refreshApex just to grab fresh data from the server.

My save:

    let criteriaToSave = [];
    //reassemble drill up/down fields on the criteria
    for(let i = 0; i < this.tableData.length; i++){
    //pass tableData to apex to save.
    saveCriteriaUpdates({criteriaJSON: JSON.stringify(criteriaToSave), criteriaApiName: this.objectName})
        .then(result => {
            this.showButtons = false;
            return refreshApex(this.wiredResults);
            //Show toast on success/error
        }).catch(error => {
            //Show toast on error

This works. The refresh apex actually causes the wire function to execute again.

My cancel:

    this.showButtons = false;

This does not work. I have tried returning the refreshApex in the cancel as well with no luck. It seems to be fine when called in the promise of an Apex method call... but not working when just... called. It just does nothing, there aren't even errors in my wire function, it does not refresh it at all.

How can I do a refreshApex on button click outside of an Apex method call promise?

  • When you say it does not refresh, are you saying that cancelUpdates() is never called? Have you tried putting some logs in that function? Also if you want to re-render your component, you will need to utilize a tracked property, do you have one?
    – Jayant Das
    Commented Apr 5, 2019 at 15:50
  • CancelUpdates is called. When I trigger saveCriteria with my button, the console logs from my wire function appear in my Dev console. When I click cancel and trigger cancelUpdates, the function triggers, but my wire function is silent. I've placed debugs all over my wire function in case there was some error, but nothing, it just doesn't refresh it. Commented Apr 5, 2019 at 15:58
  • Actually I realize that I had encountered same thing that console logs don't work as expected in imperative refresh but the function does get invoked, most likely it just utilizes the cache. Do you have a tracked property to make sure you are re-rendering the data?
    – Jayant Das
    Commented Apr 5, 2019 at 16:16
  • I think your issue may be related to this question. Take a look and see if the answer there works for you.
    – Jayant Das
    Commented Apr 5, 2019 at 16:22

1 Answer 1


This is happening because the underlying cached data has not changed. The javascript wire method will only be called if it detects a change in the data returned.

You must log in to answer this question.

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