7

In communities, I have embedded a lightning components that edits the record in another form component and on save it redirects back to detail layout.

The problem I am facing is after update when it redirects, I can see old values, while when i Query/refresh page i can find new values.

Code used for redirection.

             var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
                "recordId": oppId,
                "slideDevName" :'related'
            });
            $A.get('e.force:refreshView').fire();/** Added as per suggestion **/
            urlEvent.fire();

Somewhere in between Lightning container is showing me old values. Can someone give me some pointers on this issue?

  • So I think you had declared a attribute from which records are updated. So just before redirecting fire an event and update that attribute with updated values... – Muzammil Bajaria Jan 29 '17 at 13:55
  • I update record in APEX. Redirect to standard detail view of record. Why should i update value of an attribute if am redirecting to detail page. – Pranay Jaiswal Jan 29 '17 at 13:58
  • You are redirecting to lightning component? If yes, then either in init you meet to update attribute or refresh using events.. – Muzammil Bajaria Jan 29 '17 at 14:01
  • Am not redirecting to a custom lighting component. e.force:navigateToSObject is standard lightning compoent provided by salesforce, whose init method is not public to override – Pranay Jaiswal Jan 29 '17 at 14:02
  • 1
    This might be an issue in their underlying data cache in Lightning. I sometimes see this when in Lightning Experience. We have a custom VF edit page for an object and about 50% of the time after editing the record on that page and saving, the record detail in lightning is still showing the old data. Note that we are using all standard mechanisms here (ApexPages.StandardController in VF and the basic Lightning Experience record page). Hopefully they fix this soon since waiting 10 to 15 seconds for a page refresh after editing really sucks. – dsharrison Feb 3 '17 at 0:02
4
+25

$A.get('e.force:refreshView').fire(); This event or this code you are using in one.app that's why this is not working.

It’s supported in Lightning Experience and Salesforce1 only.

Refer it

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_refreshView.htm

  • 1
    one.app IS the lightning experience and salesforce1. – Santanu Halder Feb 2 '17 at 10:17
  • I am using $A.get('e.force:refreshView').fire(); in lightning component in community and it is working fine. – Jai Chaturvedi Feb 3 '17 at 8:49
  • @JaiChaturvedi are you redirecting to detail page after that? Problem is in detail page which is showing the old values. – Pranay Jaiswal Feb 3 '17 at 13:23
  • No, I am not redirecting it to anywhere. Just refreshing after successful callback from server class. It just refreshes the section to include the latest inserted record in the list. – Jai Chaturvedi Feb 4 '17 at 7:51
  • When you redirect to detail page, this doesn't work. – Pranay Jaiswal Feb 5 '17 at 3:21
3

The lightning container is still buggy. As i am redirecting to detail page, I started using Javascript window methods rather e.force:navigateToSObject methods.

window.location ='/myportal/s/opportunity/'+oppId ;

redirects to opportunity and via hard page reload thus loading new values from database.

I know its not recommended by salesforce, but had no other option. Hope salesforce fixes this soon.

  • This does not work properly, when a standard button like edit is overriden with visualforce using lightning out, Salesforce is opened inside the page view and we see home tabs twice. – Raul Sep 28 '17 at 13:05
  • My question was specific to communities and was pure lightning, Lightning out was beta then. The given answer worked for me. I had raised bounty too, no solution worked then. – Pranay Jaiswal Sep 28 '17 at 14:29
  • Ah gotcha, but same behavior if I use a component to override a standard action. I guess your scenario was completely different. – Raul Sep 28 '17 at 14:31
  • Thanks mate :) Not all pain has same remedy :) cheers – Pranay Jaiswal Sep 28 '17 at 15:03

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.