0

I have three objects ObjectA, ObjectB, ObjectC. ObjectA is the grand parent, ObjectB is child of A & Object C is child of B. I'm providing a button on ObjectA page layout to create/edit records for objectB & ObjectC.

I have a page in which the user can perform the operations for child objects B &C.

User can insert/update record for Object 1, insert/update/add attachment for Object 2.

Both the object operations are shown in two different page block and operations for ObjectC should appear only after ObjectB updates.

Here, the problem is I want to set the savepoint on page load & if the user cancel the operation in any page block, I should rollback all the DML operations done so far and then redirect to ObjectA page detail.

How can I achieve this?

1 Answer 1

2

No. Database.SavePoint is only valid during a single execution context. A Database.Savepoint does not persist across execution contexts. You cannot start a transaction and then return to your client webpage in order to get additional data to post to another record. I suggest that you collect all information for B and C and save at the same time instead of the user saving B and then moving on to C. If this is not possible then you should implement a controller method 'Cancel' that deletes B if user cancels while entering C. If A should also be deleted then you can add additional logic to delete. Refer to this Transaction Control in the Apex developers guide.

1
  • @Priyanka Does this answer your question Sep 28, 2015 at 15:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .