I have two objects - Project and Resource . Project is a lookup field on Resource. So in Project there is a related list called Resources.

Now in Resource , I have created a list button "Add project Resource" which calls a VF page(having custom controller). There is a commandbutton on the VF page like this

<apex:commandButton value="Save" action="{!save}"/>

and in controller

public PageReference save()

 //....do some calculation
 //...insert a new resource....
   return new Pagereference('/'+project.id);

So basically it creates a new resource and navigates back to its parent project . Problem this when I am Switching to lightning experience , it does navigate to the project record but its resource related list is not updated. I need to refresh the project record manually and then it shows the newly added resource in the resource related list.

Is there some cache problem ?

I have tried using sforce.one.navigateToSObject("{!project.id}") when its lightning but same problem occurs.

Please help.

2 Answers 2


Indeed, just redirecting to the record will not fire a refresh event. However, sforce.one.back takes a "refresh" parameter, so if you only need to go back to the record you were on (a "nav back") you can just use sforce.one.back(true).

There's an [example of this as a VF component][https://github.com/SalesforceFoundation/Cumulus/blob/dev/src/components/UTIL_NavigateBack.component] in the NPSP:

<apex:component >
    <apex:attribute name="recordId"
        description="The recordId to navigate to."
    <apex:attribute name="redirect"
        description="Prevent redirect unless set to true."

    <script type="text/javascript">
        var redirect = {!redirect};
        if (redirect) {
            if ((typeof sforce != 'undefined') && sforce && (!!sforce.one)) {
                // Manage navigation in Lightning Experience & Salesforce1
            else {
                var recordId = '{!recordId}';
                // Manage navigation in Salesforce Classic
                window.parent.location.href = '/' + recordId;

  • Strangely still it fails sometimes....problem is its very unpredictable.....Usually its failing for the first time (when it navigates back and lands on the detail tab of the record , when I click on related list tab the resource related list is being shown as empty although we have added a resource) . Any other solution @ChristianCarter ?? Dec 6, 2016 at 15:17
  • Lightning maintains the cache for resource map layout and set it's respective refresh time. Every time we redirect from custom page to detail page, UI not reflecting it's updated value. sforce.one.back(true) is also not working in MS Edge because given method work on state and MS edge saving every stages in session. How can we forcefully refresh view in lightning?
    – dgk
    Mar 1, 2017 at 13:18
  • Using sforce.one.back(true) hasn't worked for me at all and the page is not being refreshed.
    – John_Henry
    Jun 21, 2017 at 17:20

Can you try out using <apex:commandLink> instead of <apex:commandButton> and perform navigation from javascript.

<apex:commandLink value="Save" action="{!save}" oncomplete="return handleRedirect()"
    function handleRedirect() {
            if((typeof sforce != 'undefined') && sforce && (!!sforce.one))
            } else {
                window.location.href = '<your url>';


You must log in to answer this question.

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