I am using connection.js and apex.js to add DML operations to a custom VisualForce page with sforce.connection.

There are actions in the page that can make multiple calls that will alter data. I'd like to add transactional safety to these actions, so that if a single statement fails, then all the previous statements within the transaction will be rolled back.

I know this is easy enough with Apex eg:

Savepoint sp = Database.setSavepoint();

// Do something...

// Rollback if required

I'd like to know if there is a way to do this when using the sforce javascript object.

  • No references to Savepoint in the documentation or glossary. – Adrian Larson Sep 19 '16 at 12:42
  • 1
    Yeah I couldn't find anything in the docs either, which is why I optimistically turned to here. I was wondering if it was called something else, or was maybe poorly documented. I also checked the sforce object itself and couldn't see anything in there that looked like it would do this. – Chris Payne Sep 19 '16 at 12:44

The problem you face here is that each operation is a self-contained transaction. So you don't have the same options available to you. If you want to use transaction control, you need to use Apex so that all of your operations are, in fact, wrapped in one transaction.

The documentation on the AJAX Toolkit is completely devoid of any reference to Savepoint.

| improve this answer | |
  • 1
    This is probably the most regrettable part about the APIs. SOAP, REST, and Bulk all suffer from this design flaw. – sfdcfox Sep 20 '16 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.