I have a scenario, wherein I display a Warning message using toast when the record is updated to meet certain criteria. I am trying to use a combination of @wire and imperative apex.

Below is the code snippet:

@api recordId;
    bShowToast = false;
    @wire (getRecord, {recordId : '$recordId' ,fields: [ 'Claim__c.StartDate__c']})
    getClaimRecord({error , data}){
            // eslint-disable-next-line no-console
            console.log('data : ' ,data);  
        }else if(error){
            this.error = error;
showToast() {
        verifyEndDate({sClaimId: this.recordId}) //imperative apex call
        .then(result =>{
            // eslint-disable-next-line no-console
            console.log('result : ' ,result);
            this.bShowToast = result;
            // eslint-disable-next-line no-console
            console.log('bShowToast : ' ,this.bShowToast);
                    new ShowToastEvent({
                        title: 'Get Help',
                        message: 'ACTION REQUIRED...',
        .catch(error => {
            // eslint-disable-next-line no-console
            console.log('Error Occured : ' ,error);

I send the value from apex method to display toast based on certain values on the record (majorly depend on changes to a single field).

Now, the problem is that it retains the value from very first apex call and the value doesn't change even if the back-end method is supposed to send other value. Eg: if on page/component load - the method returns true, it'll display same value even if I update the record to make the value as false. I tried using refreshApex() but that didn't work for me.

Any idea how this can be achieved.

When trying to use Aura component to force refresh.. I can't even find the aura component on custom component list. I have no experience with aura and directly started with LWC.. Below is the code for aura components:

<aura:component >
    <c:claimWarningMessage onrecordChange="{!c.refreshView}" ></c:claimWarningMessage>


    refreshView: function(component, event) {
    // refresh the view

I added below line in showToast() method...

this.dispatchEvent(new CustomEvent('recordChange'));

Any idea why I'm not able to see the component in custom component list?

  • You are updating that value on UI or in backend by some other process? Commented Nov 19, 2019 at 20:22
  • @PranayJaiswal I'm updating it on record page itself where the component is placed. Commented Nov 19, 2019 at 20:36
  • verifyEndDate only contains recordId are you also sending the updated value of record? Commented Nov 19, 2019 at 20:39
  • @PranayJaiswal I'm only sending the recordId and the apex method queries the record using the id. Ideally, apex method should be able to retrieve the updated record and send back the appropriate value but that's not happening at all. Commented Nov 19, 2019 at 20:42
  • So, there is another component, page that updates the value of record, but the your lwc component still shows the old value? Commented Nov 19, 2019 at 20:44

1 Answer 1


You are using standard record SF save. The record Save will fire refreshView event. Unfortunately, lwc cant listen to refresh view event natively and react to it. You have to use an aura wrapper around it.



<aura:handler event="force:refreshView" action="{! c.refreshLWC}" />
<c:customLWCComponent aura:id="myLWCCompnent"></c:customLWCComponent>

Aura Controller:

refreshLWC: function(component, event, helper) {

Then in your lwc:

 @track backupObjClaim;
        this.backupObjClaim= result;


    refresh(){//this method is called from aura
        return refreshApex(this.backupObjClaim);

src: https://salesforce.stackexchange.com/a/257396/19118

  • I tried doing something similar but it doesn't work.. I'm not able to see the aura component in list of custom components.. I have updated the question.. please scroll down to bottom Commented Nov 19, 2019 at 22:04
  • You have to create one of your own. That will contain your lwc Commented Nov 19, 2019 at 22:05
  • that's exactly what I did.. Commented Nov 19, 2019 at 22:07
  • Why are you firing $A.get('e.force:refreshView').fire();, you have to listen to this event. Commented Nov 19, 2019 at 22:12

You must log in to answer this question.

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