1

I am trying to clear the cache of my wire method. But I have added refreshApex in my code but I am getting error

Error: Refresh failed because resolved configuration is not available.

My Code

import { refreshApex } from '@salesforce/apex';

export default class LwcCaseCritical extends LightningElement {

caseCriticalControllerApex

/**
*   @description: Get case information On page load
*                 
*/
@wire(caseCriticalControllerApex, {caseid: '$recordId'})
    getcaseCriticalControllerApex({error, data}) {

        if (data) {

            console.log('inside case Critical ControllerApex ');

            this.caseCriticalControllerApex = data;
            __showComponentLoader(this, '.pageLoader');
            console.log('recordId ', this.recordId);
            this.cases = data;
            console.log('CriticalFlag ', this.cases.CriticalFlag__c);
            this.oldPriorityValue = this.cases.Priority;  
            this.caseObject.CriticalFlag__c = this.cases.CriticalFlag__c;
            this.caseObject.Priority = this.cases.Priority;
            __hideComponentLoader(this, '.pageLoader');

        } else if (error){
            console.log(error);
        }
    }

 /**
*   @description: On click of save button
*                 
*/    
save(){
    __showComponentLoader(this, '.pageLoader');

    //this.cases.Id = this.recordId;
    this.caseObject.Id = this.recordId;

    console.log('cases details ' , this.cases);
    console.log('caseObject details ' , this.caseObject);

    saveApex({newCase : this.cases, updatedCaseValuse :this.caseObject, 
             errorMessage : '', oldPriorityValue: this.oldPriorityValue})
        .then(result => {
            this.errorMesage = result;

            if(this.errorMesage !== null && this.errorMesage !== ''){
                __showNotification(this, 'Case',this.errorMesage, 'Error', '');
            }else if(this.errorMesage === null || this.errorMesage === ''){
                __showNotification(this, 'Case','Case Updated', 'Success', '');
                this.refreshConsolePage();

                if(this.isEsclation === true && this.is3rdLevelUser === false){
                    const clickedevt = new CustomEvent('savecomplete', {
                        detail: { close : true },
                    });        
                    // Fire the custom event
                    this.dispatchEvent(clickedevt);
                }else{
                    const clickedevt = new CustomEvent('savecomplete', {
                        detail: { close : false },
                    });        
                    // Fire the custom event
                    this.dispatchEvent(clickedevt);
                }
            }

            console.log('this.isEsclation  ' + this.isEsclation );
            console.log('this.is3rdLevelUser  ' + this.is3rdLevelUser );
            /*
            refreshApex(this.overrideCaseIfNeededApex); 
            refreshApex(this.showPriorityApex);
            refreshApex(this.caseCriticalControllerApex); 
            */ 
            __hideComponentLoader(this, '.pageLoader');
            return refreshApex(this.caseCriticalControllerApex); 
        })
        .catch(error =>{
            console.log('error data ::: ' , error);
        });
}

}

Do any one have nay idea why I am getting this error on click of button.

2

For refreshApex to work, you need to pass complete response, not just the data part.

import { refreshApex } from '@salesforce/apex';

export default class LwcCaseCritical extends LightningElement {

caseCriticalControllerApex

backupResponseFromWire;


@wire(caseCriticalControllerApex, {caseid: '$recordId'})
    getcaseCriticalControllerApex(resp) {
        this.backupResponseFromWire = resp;
        var data = resp.data;
        var error = resp.error;
        if (data) {

            console.log('inside case Critical ControllerApex ');

            this.caseCriticalControllerApex = data;
            __showComponentLoader(this, '.pageLoader');
            console.log('recordId ', this.recordId);
            this.cases = data;
            console.log('CriticalFlag ', this.cases.CriticalFlag__c);
            this.oldPriorityValue = this.cases.Priority;  
            this.caseObject.CriticalFlag__c = this.cases.CriticalFlag__c;
            this.caseObject.Priority = this.cases.Priority;
            __hideComponentLoader(this, '.pageLoader');

        } else if (error){
            console.log(error);
        }
    }

and then in your save method

return refreshApex(this.backupResponseFromWire);

| improve this answer | |
  • very close but missed very important things. Thanks for your help. – Anu Nov 21 '19 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.