0

I am trying to refresh the parent from the child. From the Parent,I am opening a modal window for update. Once I save the record, modal window close and the parent section should be refreshed.

Created an event - RefreshTemplate.( ).

In the Parent I refer that

On the Parent Controller ,

handleComponentEvent : function(component, event, helper){
    var message = event.getParam("message");
    var caseId=component.get("v.recordId");
        console.log('Inside handleComponenetEvent'+ caseId);
     var action=component.get("c.getCaseTriageInfo"); 
        action.setParams({
            caseId:caseId
        });


    action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === 'SUCCESS'){
                //var srId=component.get("v.parentIdToRefresh");
                $A.get('e.force:refreshView').fire();
            } else {
                 //do something
            }
        }
    );
    $A.enqueueAction(action);
}

On the Child Modal Window: I registered the event

and on the helper - after Sucessfull Update message ,I am firing the event

var event = component.getEvent("lightningEvent");
            event.setParams({
                "message" : "MESSAGE TEST" });
            event.fire();

        })

Not sure if I am missing anything here.

6
  • you are firing refresh in the callback in success , did you check if the response is success? – User6670 May 20 '20 at 18:24
  • Yes, I put some display in the handleComponentEvent action and I see the Service Request Id and the message fired from the event from the Child – Regi Varghese May 20 '20 at 18:33
  • you can try putting a handler for refresh view and reinitialize the component like this <aura:handler event="force:refreshView" action="{!c.doInit}" /> ,if you have any initialization function – User6670 May 20 '20 at 18:43
  • I get this message in the console: AuraAlohaFrameNavigator.js:156 [LEXI:navigator:communication] failed to connect with lightning experience WindowMessengerTimeoutError: Timeout exceeded waiting for handshake to complete from parent at new b (farmerssrm--sodev6--vlocity-ins.cs50.visual.force.com/jslibrary/…) at farmerssrm--sodev6--vlocity-ins.cs50.visual.force.com/jslibrary/… – Regi Varghese May 20 '20 at 18:45
  • at what point do you get this error ,when you refresh the page.? – User6670 May 20 '20 at 20:00
0

Per this Salesforce Developer forum question, be sure to add a handler event to your aura component, such as:

<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />

with the controller like:

saveAccount : function(component,event,helper){

    var saveAccountAction = component.get("c.accountSaved");
    // your code to send contact details to server

    actionSave.setCallback(this, function(saveAccountAction) {
        if (saveResult.state() === "SUCCESS") {
            //contact saved Successfully
            //Fire the refresh view event to update Account detail view
            $A.get('e.force:refreshView').fire();

        }else if (saveResult.state() === "ERROR") {
            console.log("Error Saving Contact ");
        } 
    });

    $A.enqueueAction(saveAccountAction);
},
/*page refresh after data save*/

isRefreshed: function(component, event, helper) {
    location.reload();
},
/*page refresh after data save*/

I have also successfully used

window.location.reload();

Such as

testHelper : function(component, event) {
    //helper body

    //invoke the Apex method
    $A.enqueueAction(action);
    //close quickaction window
    $A.get("e.force:closeQuickAction").fire();
    //reload page to display updated information
    window.location.reload();
}

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.