I have created one lightning web page with some input and output fields and a lightning button, now I want the page to be refreshed automatically when I hit the lightning button can someone help to do the same?

I have tried $A.get('e.force:refreshView').fire();

but after hitting the button I get the below error.

This page has an error. You might just need to refresh it.
Action failed: c:RegistrationForm$controller$closeMessage [Cannot read property 'fire' of undefined]
Failing descriptor: {c:RegistrationForm$controller$closeMessage}

when I click the submit button a pop comes up with the message and the OKAY button now when I click the okay button I want the page to be refreshed below is the pop up code

<aura:if isTrue="{!v.message}">
        <div class="demo-only" style="height: 24rem;">
            <section role="alertdialog" tabindex="-1" aria-labelledby="prompt-heading-id" aria-describedby="prompt-message-wrapper" class="slds-modal slds-fade-in-open slds-modal_prompt" aria-modal="true">
                <div class="slds-modal__container slds-col slds-size_4-of-12">
                    <header class="slds-modal__header slds-theme_success slds-theme_alert-texture">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close">
                            <span class="slds-assistive-text">Close</span>
                        <h2 class="slds-text-heading_medium" id="prompt-heading-id">Information saved</h2>
                    <div class="slds-modal__content slds-p-around_medium" id="prompt-message-wrapper">
                        <p class="slds-align_absolute-center">Your information has been saved successfully!</p>
                    <footer class="slds-modal__footer slds-theme_default">
                        <button class="slds-button slds-button_neutral"
            <div class="slds-backdrop slds-backdrop_open"></div>

controller of the okay button to close the pop-up message

closeMessage : function(component, event, helper) {
        component.set("v.message", false);

in my lightning component, I am not using any aura handler related to refreshing the page

Please correct me if I am not using the right approach

Thank you in advance

  • 2
    where are you testing this component? in a lightning community, an app? additionally, if oyu can include a minimal reproduceable code sample, it will be easier to provide feedback. thanks! – glls Jul 26 '18 at 15:11
  • I am getting the error after previewing the lighting component from the lightning application – gs650x Jul 26 '18 at 15:13
  • if you test it in lighting communites or LEX not using the app preview from the developer console do you still get the error? – glls Jul 26 '18 at 15:14
  • The error seems to be occurring in closeMessage() in Controller JS in 'RegistrationForm' component. Are you able to post its code? I don't think the problem is in $A.get('e.force:refreshView').fire(); – Lightning Evangelist Jul 26 '18 at 15:15
  • @gllsI did not try in app-builder – gs650x Jul 26 '18 at 15:56

Are you in the context of a custom lightning app? The default refreshView event is only available within the Lightning Experience / mobile Salesforce-App context. Say if you want to use the event within a .app you have to register and handle the event manually and cannot use the out-of-the-box behavior.


| improve this answer | |
  • I am using exactly the same but not setting any parameters as I am using force: refreshView but still not able to solve the problem error message is still the same and it is not reloading the page – gs650x Jul 26 '18 at 16:18
  • @gs650x - what christian is saying is that the e.force:refreshView event won't work if you trigger it from specific places like a custom lightning app. From which context do you run your app? – Itai Shmida Jul 29 '18 at 10:56
  • I am using the lightning app to preview the component, is there any other way to refresh the page? – gs650x Jul 31 '18 at 8:18
  • As you are the owner of the Lightning App, just define a custom event and handle it on the top level app by yourself - do whatever is necessary, but there is no out-of-the-box behavior. If you want to have a hard page refresh, you should look for an JavaScript reload – Christian Menzinger Jul 31 '18 at 12:15

Have you looked at lightning:notificationsLibrary?

From the docs:


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <lightning:notificationsLibrary aura:id="notifLib"/>
    <lightning:button name="notice" label="Show Notice" onclick="{!c.handleShowNotice}"/>


    handleShowNotice : function(component, event, helper) {
            "variant": "success",
            "header": "Information saved",
            "message": "Your information has been saved successfully!",
            closeCallback: function() {
                alert('You closed the alert!');
                component.set("v.message", false);
| improve this answer | |
  • Thank you for the above information but this is an alternative to pop up message, this won't reload the page – gs650x Jul 26 '18 at 16:20
  • Call the refresh logic from within closeCallback. I updated the answer a bit. See if that helps? If not, it would be best if you include your full code. – Lightning Evangelist Jul 26 '18 at 16:25
  • I have created a new component and pasted the above code now below is the error I am getting in the console : aura_prod.js:854 null "Definition does not exist on the client for descriptor:markup://lightning:overlayInteropWrapper. Client side caches have been cleared. Please reload the page." (anonymous) @ aura_prod.js:854 Welcome_to_lightningApp.app:1 Uncaught (in promise) Definition does not exist on the client for descriptor:markup://lightning:overlayInteropWrapper. Client side caches have been cleared. Please reload the page. – gs650x Jul 26 '18 at 16:47
  • What is the API version of your component? lightning:notificationsLibrary requires API version 41.0 and later. – Lightning Evangelist Jul 26 '18 at 17:01
  • API version is 43.0 – gs650x Jul 26 '18 at 17:11

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.