Whats the lwc equivalent of this aura event?



I had this issue myself today as well. In my case, I had a Quick Action Lightning Aura Component which enveloped a Lightning Web Component (because there is currently no way of using a Lightning Web Component as a Quick Action)..

What I did is set up my Aura Component to catch 'close' events:

<!-- aura/auraComponent/auraComponent.cmp -->
<aura:component implements="force:lightningQuickAction,force:hasRecordId">
    <c:webComponent recordId="{!v.recordId}" onclose="{!c.handleClose}" />

And process them with the events I would LIKE to throw from my Web Component:

// aura/auraComponent/auraComponentController.js
    handleClose: function() {

And in my Web Component I throw the following Custom Event to trigger the refresh & quick action close:

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

I know it's ugly, but at the time of writing I don't think there's a better way to refresh an underlying record page & close a Quick Action modal from a Lightning Web Component.

| improve this answer | |
  • I have copied your code. closeQuickAction works, but not refreshView. I have tried single quotes and double quotes (you mixed them), but that does not make any difference. Does the refresh update the related lists in your case? – Sander de Jong Mar 4 at 8:07
  • 1
    No, actually - it refreshes my record detail page but not the related lists. It might be to do with this known issue: success.salesforce.com/issues_view?id=a1p3A000000mDOuQAM – Koen Wesselman Mar 6 at 8:16

call the refreshApex () method if you want to get result from the SF

import apexMethod from '@salesforce/apex/Namespace.Classname.apexMethod';
@wire(apexMethod, { apexMethodParams })

    // opportunitiesOverAmount.js
import { LightningElement, api, wire } from 'lwc';
import { refreshApex } from '@salesforce/apex';
import getOpptyOverAmount from '@salesforce/apex/OpptiesOverAmountApex.getOpptyOverAmount';
import updateOpptyStage from '@salesforce/apex/OpptiesOverAmountApex.updateOpptyStage';

export default class OpportunitiesOverAmount extends LightningElement {
    @api amount;

    @wire(getOpptyOverAmount, { amount: '$amount' })

    handleClick(e) {
            stage: 'Won'
        .then(() => {
            return refreshApex(this.opptiesOverAmount);
        .catch((error) => {
            this.message = 'Error received: code' + error.errorCode + ', ' +
                'message ' + error.body.message;
| improve this answer | |
  • This helps updating the value of @wire property. But $A.get('e.force:refreshView').fire(); is used to tell OTHER components that things need to refresh. – zaitsman Feb 22 '19 at 1:15
  • 1
    Yes that is correct @zaitsman, I need to tell other components that things need to be refreshed. – user64922 Feb 25 '19 at 6:05

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.