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
brielea1984brielea1984 

Standard Cancel Button

My client is frustrated that at times, when they click the "Cancel" button in an edit page, Salesforce takes them back to the home page rather than back to the previous page. I know how to make an easy "back" button, but it can only be presented on the detail page (I don't want to rebuild all of my objects in visualforce). Is it possible to hack into the "Cancel" button and override it to have it redirect the user to the previous page?

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

You cannot "hack" the standard cancel button (at least, not easily; it might be technically possible, but I wouldn't advise it). The standard cancel button redirects to the retURL. If you make buttons that do not include this parameter, cancel will indeed send them to Home. You should include a retURL in your buttons and links to make sure the user returns to the correct place.

All Answers

sfdcfoxsfdcfox

You cannot "hack" the standard cancel button (at least, not easily; it might be technically possible, but I wouldn't advise it). The standard cancel button redirects to the retURL. If you make buttons that do not include this parameter, cancel will indeed send them to Home. You should include a retURL in your buttons and links to make sure the user returns to the correct place.

This was selected as the best answer
Karthik B.ax1475Karthik B.ax1475

Hi,

 Even if it is standard or custom objects when user clicks on cancel it will redirect to page from which it came. But i dont know why this happens in you org.

 

Regards,

Karthik

brielea1984brielea1984

I think it's happening from my custom buttons that direct to another object, and when they hit cancel this happens. The first response seems to be the solution.

 

Thanks everyone! I'll check it as solved when I get it to work.