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
Sharmila Sahu 12Sharmila Sahu 12 

we have one visulaforce tab that is launching VF page.In lightning when I click on cancel button it is giving error.

We have one visulaforce tab that is launching VF page.VF page has standardcontroller and extension on Opportunity. When I click on cancel button in Classic it is taking me to Home Page But in lightning it is throwing error.Any idea how to make this standard Cancel button work on VF page in lightning to properly redirect.

User-added imageWhen Clicking on Cancel Button it is throwing error.
User-added imageAny idea how to make this standard Cancel button work on VF page in lightning to properly redirect.
 
SabrentSabrent
first check if the visualforce page is enabled for lightning ? 

from set up > type 'Visualforce Page' in the quick find box 
locate the Visualforce Page > Click to open > Edit 

User-added image
GauravendraGauravendra
Hi Sharmila,

You can override the cancel button in the apex to return null. In that way you can avoid the error in lightning.
If you want to redirect to particular page, create a  PageReference variable and return that.

Hope that helps!
Sharmila Sahu 12Sharmila Sahu 12
@Rov
I enabled it for lightning.Still I am facing same error message. The page no longer exists when clicked on Cancel button.
Sharmila Sahu 12Sharmila Sahu 12
Hi Gauravendra,

When I tried return null in cancel button, it is not getting anywhere. When I am clicking on cancel button, it is remaining on same VF page.

How to redirect it to Opp Home Page after clicking on Cancel button both in classic and lightning?
 
Sharmila Sahu 12Sharmila Sahu 12
I found a way to do it using 
<input type="button" class="btn" value="Cancel" onclick="window.location = '{!URLFOR($Action.Opportunity.Tab, $ObjectType.Opportunity)}'" />
But it is showing classic Opp home page view even in lightning.User-added image
PFA Image where it is showing classic Opp homepage even in lightning. How to change it so that it will show classic opp home page when in classic and Lightning Opp home page when in lightning.
Ap30Ap30
Hello,
Please share the workaround if u have.