2

Context:

I'm building a lightning component to override the New action for a custom sObject, let's call it My_Object. My_Object has a master detail relationship with Contact (My_Object is the detail). The way user's are going to create a new My_Object is by clicking on the New button of the My_Object related list on Contact.

I can navigate back to the Contact, but it requires a refresh to see the new My_Object in the Related List.

What I want:

I want to navigate back to the (master) Contact's page and see my newly created My_Object without requiring the user to manually refresh the page.

What I tried:

I have a helper function to do this navigation:

navigateToContact: function(component) {
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
        "recordId": component.get("v.contact.Id") // this is the ID of the parent record
    });

    navEvt.fire();
}

This works for getting me to the page, but I can't see my new My_Object in the related list on Contact until I refresh the page.

  • I tried force:navigateToSObject as shown above
  • I tried using force:navigateToURL (by concatenating a URL with the record id), with the same result
  • I tried using force:navigateToURL and adding a query string in the hopes of overcoming some kind of caching.
  • I have unchecked Enable secure and persistent browser caching to improve performance in Session Settings
  • Have you tried force:refreshView? – sfdcfox Jan 4 '18 at 2:53
  • @sfdcfox I considered it, but I don't know where I would fire it. If I put it immediately after firing the navigation event, then it just prevents the navigation and I stay on the same page. – Nathan Hinchey Jan 4 '18 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.