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
Chetan PradhanChetan Pradhan 

Visualforce Cancel button taking to home page in Lightning

I have a visualforce page being used in Lightning. The default Cancel button takes me to the home page of Lightning rather than the record page from where I clicked on the New button. However, it works fine in Classic. Any help would be really appreciated.

I have tried adding following method in the controller, but that didn't help.

public PageReference cancel(){     
        return controller.cancel();
    }

Visualforce Line: 
<apex:commandButton value="Cancel" action="{!cancel}"/>

Thanks,
Chetan
Raj VakatiRaj Vakati
See the Reference here 

https://salesforce.stackexchange.com/questions/190462/implement-a-back-or-cancel-button-in-a-lightning-component-in-a-vf-page-in
Shubham saini 14Shubham saini 14
Hello chetan,
public PageReference Cancel(){

return null;

}

Let me know if it is working.
Ap30Ap30
Hello,
Please share the workaround if you have.