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
SAHG-SFDCSAHG-SFDC 

Cancel method in Apex

I have a cancel method in Apex controller which saves even if the user clicks cancel

 public PageReference cancelSave() {
           
            return null; 

I  need the user to stay on the same page when cancel is clicked (Cannot use standard cancel)
DeveloperSudDeveloperSud
Hi,

Follow these below links and you will get the logic.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm 

public PageReference cancelSave() {
           // add your logic here, like the required DML statement (insert /update) of the record you want to save
            return null; // this will make the user stay on the same page
}