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

Savepoints and Cancel

So I have a class that uses a VF button which essentially works like a trigger to create a new opportunity with line items and takes the user to the new opportunities standard edit page.  So once the user sees anything after hitting the "Clone" button the opportunity and line items have all been created.  At this point if they hit cancel from the edit page it doesn't actually cancel anything - the cloned opp and it's line items are all still there.  It just takes them to the Cloned Opp's detail page.  Is there a way to use Savepoints to tell it if they hit cancel at that point in time I want it to go back to my save point?  I have a save point in my controller class but most examples use an error, which I'm not wanting to use an error.  I've also seen "On Cancel" used when a full VF page is used but in this case they are just being taken to the standard edit page of the new opportunity via
return new PageReference('/''/e?retURL=%2F';
perhaps there is something I can add to this return new PageReference that could somehow contain the rollback?

Gaurav KheterpalGaurav Kheterpal
Have you tried using a flag to determine at what point user cancelled? And then based on the value of the flag, you can do the appropriate handling.