• booz
  • 0 Points
  • Member since 2015
  • Developer
  • Cloud Sherpas

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

I have a custom save method that sets a Savepoint, does some inserts and either rolls back (using Database.rollback) if there's an error or redirects to one of the newly inserted records. I just started testing the roll back functionality and it is not working as I would expect. The insert is in fact rolled back, but instead of being sent back to the Visualforce page I was just on, I am sent to a Salesforce error page saying "Data Not Available". It seems to me like the roll back might be removing the view state of the Visualforce page or something strange.


public PageReference save() {
	Savepoint beforeInserts = Database.setSavepoint();
	if (trySave() == true) {
		return (new ApexPages.StandardController(record)).view();
	return null;

private boolean trySave() {
    //do some validation and such
    try {
        insert record;
    catch (Exception err) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, err.getMessage()));
        return false;
    return false; //to test the roll back

 Has anyone seen something like this?



  • November 19, 2011
  • Like
  • 0