I am having trouble displaying information about changed fields on a record through use of a LWC Quick Action that is submitting records for approval with pre filled comments.

I am hoping to be able to refresh my apex queries on record save, as the record needs a full page refresh in order to display changed values. Below is my LWC component / Apex code.

I am having trouble how to call refreshApex() when the component is being loaded via quick action ( it is being wrapped by aura component ) and can do refresh apex with the click of a refresh button but cannot get it to automatically refresh on component load

    import { LightningElement, track, api, wire } from 'lwc';
    import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
    import { ShowToastEvent } from 'lightning/platformShowToastEvent';
    import { updateRecord } from 'lightning/uiRecordApi';
    import { refreshApex } from '@salesforce/apex';
    import startApproval from '@salesforce/apex/LWCSubmitForApproval.approvalInit';
    import getApprovalComments from '@salesforce/apex/LWCSubmitForApproval.getApprovalComments';
    //import isLocked from '@salesforce/apex/LWCSubmitForApproval.isLocked';
    import IS_LOCKED from '@salesforce/schema/Account.Is_In_Approval__c';
    const fields = [IS_LOCKED];
    export default class lwcSubmitForApproval extends LightningElement {
        @track error;
        @track openModal = true;
        @track isLocked;
        @api recordId; // Account Id
        @wire(getRecord, { recordId: '$recordId', fields })
        @wire(getApprovalComments, { accId: '$recordId' })
    //    @wire(isLocked, { accId: '$recordId' })
    //    isLockedWired;
        get approvalComments(){
            return this.approvalCommentsWired && this.approvalCommentsWired.data;
    //    get accIsLocked(){
    //        return this.isLockedWired.data;
    //    }
            return refreshApex(this.approvalCommentsWired);
                this.openModal = false;
        // onclick button handler
        submitForApproval() {
            let accLocked;
            if(getFieldValue(this.Account.data, IS_LOCKED) === true){
                accLocked = true;
            if(accLocked === true){
                            new ShowToastEvent({
                                title: 'Account Locked',
                                message: 'The account is currently in approval process.',
                                variant: 'error'
                                accId: this.recordId,
                                comment: this.approvalCommentsWired.data
                            .then(result => {
                                    new ShowToastEvent({
                                        title: 'Success',
                                        message: 'The account has been submitted for approval, refreshing page...',
                                        variant: 'success'
                                // Display fresh data in the form
                                setTimeout(function() { window.location=window.location;},2000);
                                return refreshApex(this.approvalCommentsWired);


        public static String getApprovalComments(Id accId){
            String approvalComments;
            List<Account> accountList = [SELECT Id, Start_Approval__c, Start_SSB_Approval__c, Start_Financial_Approval__c, Payment_Method_Changed__c, SAP_Payment_Terms_Changed__c, Start_OD_Approval__c, Start_Address_Approval_Description__c,
                                            Start_SSB_Approval_Description__c, Start_Financial_Approval_Description__c, Start_PM_Approval_Description__c, Start_SAP_Payment_Terms_Description__c, Start_OD_Approval_Description__c FROM Account WHERE Id =: accId];
            for(Account a : accountList){
                    approvalComments = a.Start_Address_Approval_Description__c;
                } else if (a.Start_SSB_Approval__c){
                    approvalComments = a.Start_SSB_Approval_Description__c;
                } else if (a.Start_Financial_Approval__c){
                    approvalComments = a.Start_Financial_Approval_Description__c;
                } else if (a.Payment_Method_Changed__c){
                    approvalComments = a.Start_PM_Approval_Description__c;
                } else if (a.SAP_Payment_Terms_Changed__c){
                    approvalComments = a.Start_SAP_Payment_Terms_Description__c;
                } else if (a.Start_OD_Approval__c){
                    approvalComments = a.Start_OD_Approval_Description__c;
            return approvalComments;

I need account list to be refreshed on record save, what is best way to do this? Thanks!

  • So, your quick action button is wired to 'submitForApproval'? And you success toast is getting display but the refreshApex code (after the toast code) is not working as expected?
    – arut
    Commented Aug 17, 2020 at 10:13
  • 1
    Of course, I finally find someone else with the exact issue I'm having and there are no answers.
    – Paugh
    Commented Sep 16, 2022 at 18:05


You must log in to answer this question.