function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gordon GaoGordon Gao 

Visualforce pagereference redirects to empty page on Lightning Experience

We have a visualforce page for building opportunity products.
There's a button - "Save & Exit", which calls the controller method to save the selected products and returns the pagereference - "new PageReference('/' + ApexPages.currentPage().getParameters().get('Id'));"
Basically, it tells the page to go back to the opportunity page. This works perfectly in the classic view. But in lightning, sometimes, after clicking the button, the page goes to a blank page with only lightning sidebar & top bar rather than back to the opportunity page.
Can anyone provide any thoughts on this issue?
Best Answer chosen by Gordon Gao
William TranWilliam Tran
Gordon, Visualforce is supported "in general" in Lightning - but not everything is supported.

From Salesforce Knowledge Article:
When developing Visualforce pages for the full site developers can utilize the Page Reference class to control the navigation. This method is not supported in Salesforce1 and may not work as expected. Some pages will load using Page References however this may change with any update and should not be relied on. Salesforce Support is unable to troubleshoot issues that arise from using a Page Reference for navigation in Salesforce1.

Full Description can be found here:
https://help.salesforce.com/HTViewSolution?id=000212840&language=en_US

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks

All Answers

William TranWilliam Tran
Lightning experience is similar to Salesforce1 mobile where PageReference is not supported. Instead you should navigate using sforce.one instead.

Follow this link for sforce.one spec.
https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
 
Gordon GaoGordon Gao
Thanks William. Do you mean PageReference is not supported at all or not well supported? I am a bit concerned because Salesforce says the visualforce page continue to be working in the new UI.
William TranWilliam Tran
Gordon, Visualforce is supported "in general" in Lightning - but not everything is supported.

From Salesforce Knowledge Article:
When developing Visualforce pages for the full site developers can utilize the Page Reference class to control the navigation. This method is not supported in Salesforce1 and may not work as expected. Some pages will load using Page References however this may change with any update and should not be relied on. Salesforce Support is unable to troubleshoot issues that arise from using a Page Reference for navigation in Salesforce1.

Full Description can be found here:
https://help.salesforce.com/HTViewSolution?id=000212840&language=en_US

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
This was selected as the best answer
Gordon GaoGordon Gao
I see. Thanks for your detailed answer!
Fitzgerald AnukamFitzgerald Anukam
I know this is an old question, but if you add 
oncomplete="window.opener.location.refresh();"

at the end of the commandButton, it should refresh the page. Example
<apex:commandButton action="{!onSave}" value="Save" oncomplete="window.opener.location.refresh();"/>

Since Lightning is not able to render the page, this will refresh the page on completion of the action so you don't have to refresh it yourself.
Jonathan Glass 18Jonathan Glass 18
Awsome response Fitzgerald Anukam!! Worked perfectly! Loved you enter an old question and spend time for others to get a quick answer!