I have a save and a cancel, both triggered by a button click:

    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 => {
            return refreshApex(this.wiredResults);
            //Show toast on success/error
        }).catch(error => {
            //Show toast on error

    return refreshApex(this.wiredResults);

The refreshApex() works in the then callback of the apex method call on save. I see my debugs from my wire function after saving again.

But when I just click cancel, I want to refresh my data to its original state from the server to wipe out all changes, so want to do a refreshApex(). But in the cancel, the refreshApex does nothing. I don't see my debugs from my wire function. No debugs from the error part of the wire function... my table does not refresh back to its original state... nothing.

Is there some trick to refreshApex I am missing? It seems to work in an asynchronous callback, but not a direct call like my cancel button...

PS: My wire function and extra property for refresh looks like this:


@wire(getSObjectsForTable, {stepId: '$stepId', objectApiName: '$objectName'})
    this.wiredResults = result;
        this.tableData = getTableData(result.data);
        this.tableColumns = getColumns(this.tableData, allColumns);
    } else if(result.error){
        let toastEvent = new ShowToastEvent({
            title: 'Error',
            message: 'Error retrieving records: ' + result.error,
            variant: 'error'
    this.tableLoaded = true;
  • Yes, that question answers how to do it exactly like I am doing it, and it works in an asynch callback from apex, but does nothing when I call refreshApex on button click. So... Mar 23, 2019 at 2:52
  • 1
    Most functions in LWC (wires specifically) return a promise, however according to the docs there is no promise on this function. Therefore there is no callback, so it doesn't return anything. So, like the recorded question, don't use a return.
    – tsalb
    Mar 23, 2019 at 3:54


Browse other questions tagged .