Apex Class:

public class sampleExtension {
  ApexPages.standardController std = null;
  public sampleExtension(ApexPages.standardController sc)  {
    std = sc;
  public PageReference doCancel()  {
    return std.cancel();
VisualForce Page:
Note: this doesn’t necessarily take you to the list view, it’ll return you to the last page you were viewing before going to the VF page.

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *