2

i am calling this method from the save button in lightning component.

getaVal : function(component, event, helper) {
    var updateValues = [];
    var lstInsert = [];
    var lstUpdate = [];
    var arrrr;
    var mapSize = component.get("v.fullMap");

    for (var singlekey in mapSize) {
        for(var i=0; i<mapSize[singlekey].length; i++) {
            updateValues.push(mapSize[singlekey][i]);
        }
    }

    console.log('updateValues:::',updateValues);
    arrrr = updateValues;

    for(var i=0; i<arrrr.length; i++) {
        if(arrrr[i].hasOwnProperty('Id')) {
            lstUpdate.push(arrrr[i]);   
        }
        else if(arrrr[i].hasOwnProperty('Name')) {
            delete arrrr[i].Name;
            lstInsert.push(arrrr[i]);
        }
    }

    if(lstUpdate.length !=0)
        helper.updateCounterBid(component, event, helper, lstUpdate);
    if(lstInsert.length !=0)    
        helper.insertCounterParty(component, event, helper, lstInsert);

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

}
  • Where are you viewing this lightning component? – Tushar Sharma Mar 22 '18 at 11:28
  • at custom tabs in record page – Sarvesh Mar 22 '18 at 11:38
  • 1
    Define "not working." That's a vague term. Do you see any errors on the console? How about the Developer Console logs? Any popups or messages on the screen? Can you make a Short, Self Contained, Correct (Compilable), Example that we can copy-paste to fiddle around with that demonstrates the problem? – sfdcfox Mar 22 '18 at 15:38
3

'e.force:refreshView' is available only inside the lightning container and wont be available when you use lightning out on VF . They don't work in VF / classic view or in standalone apps

0

You could try refreshing the component once your insert / update array size is not empty, like:

if( lstUpdate.length > 0 || lstInsert.length > 0  ) { $A.get('e.force:refreshView').fire(); }

(or) can you can add it inside your helper functions success result helper.updateCounterBid(component, event, helper, lstUpdate); (or) in helper.insertCounterParty(component, event, helper, lstInsert);

action.setCallback(cmp,
    function(response) {
        var state = response.getState();
        if (state === 'SUCCESS'){
            ***$A.get('e.force:refreshView').fire();***
        } else {
             //do something
        }
    }
);

Let me know if it works.

0

I have faced this issue too. Even using navigation service did not work for me. I just redirect it to the record view as below:

window.location = '/lightning/r/'+ objectApiName +'/'+ recordId + '/view';

In case anyone wants to try navigation:

<!--Add navigation service to your component-->
<lightning:navigation aura:id="navService"/>

Use the below code in a callback or action to navigate to the record:

    let navService = cmp.find("navService");
    let pageReference = {
        type: 'standard__recordPage',
        attributes: {
            "recordId": recordId,
            "objectApiName": sObjectName,
            "actionName": "view"
        }
    };
    navService.navigate(pageReference);
-2

You must put this call into a callback function like shown here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_refreshView.htm

  • hey on callback also not working – Sarvesh Mar 22 '18 at 11:40
  • Have u try to put the call after the insert/update statement inside the helper? How does this functions look like? – utm Mar 22 '18 at 12:01
  • man not working – Sarvesh Mar 22 '18 at 12:09
  • page is not refreshing – Sarvesh Mar 22 '18 at 12:10

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.