0

I created a custom action which is a lightning component to deactivate the current order and then redirect to the same page. The order is deactivated successfully but after redirecting, the order page still shows the old status until I refresh the page manually.

I have already disabled lightning experience caching but it still doesn't work very well.

Related Apex code:

    relatedOrder.ActivatedById = null;
    relatedOrder.ActivatedDate = null;
    relatedOrder.Status = 'Draft';
    update relatedOrder;
    System.debug('Finished order update');
    Order orderAfterUpdate = [Select Id, Status From Order Where Id = :relatedOrder.Id];
    System.debug('After status is: ' + orderAfterUpdate.Status); //This status has no issue

Related JS code:

    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
        "recordId": orderId
    });
    navEvt.fire();
3
  • You may be facing this known issue, even though you are not really overriding the edit button, but seems similar. Have you tried refreshing the view before navigating to the record though?
    – Jayant Das
    Commented Oct 17, 2018 at 23:38
  • @JayantDas Do you mean by code or doing it manually?
    – Lance Shi
    Commented Oct 17, 2018 at 23:56
  • In your JS, using force:refreshView. Try if that works.
    – Jayant Das
    Commented Oct 17, 2018 at 23:57

2 Answers 2

4

Try to put this $A.get('e.force:refreshView').fire(); into your controller before navigating to another object.

Controller:

$A.get('e.force:refreshView').fire();
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
    "recordId": orderId
});
navEvt.fire();
1

I was also facing the same issue, also tried with $A.get('e.force:refreshView').fire(); but it does not work for me. As it is a known issue, I finally decided to go for:-

window.location.href = '/'+recordid ;

This always gives us a properly refreshed view. I am sure this is not best practice to navigate through window function in lightning, but you can rely on it till salesforce solves that known issue.

You must log in to answer this question.

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