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.
Best Answer
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 usesforce.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: