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
MilanMilan 

Commit and Rollback

Hello,
 
We are supposed to Create leads / contacts in Salesforce using Partner WSDL. There may be times when we will be creating more than 5000 leads. So we will be invoking multiple creates (depending upon the batch size).
 
Now, if there is any error in any one of the subsequent calls. How can I rollback the earlier data that was inserted into Salesforce ?
 
I tried searching the docs and also some old postings on the forum and it seems that this feature is not available... :( I hope I am wrong .
 
Thanks,
Milan
SuperfellSuperfell
You'll need to write a compensating transaction, although its fairly unusual for people to want all/nothing behavour when they're talking about 5000 leads.
MilanMilan

Thanks for the ever quick reply. So what is a compensating transaction. Can you pelase point me to some reference implementations / docs etc.

regards,

Milan

SuperfellSuperfell
Exactly what is says, a new transaction that compensates for the initial transaction, in this particular case, you'd keep track of the successfully created leads, and if you need to "rollback" the entire thing, you would call delete for all the ones created. Again I would question the need in this particular case, I'd be surprised if this is realy what you want.
MilanMilan

Thanks Simon.

Yes, we really need the feature of ROLLBACK.

We are designing a tool wherein various salesforce users will use our tool to get leads. Once they have decided on the leads that are of their interest we will directly update them in their Salesforce account. Now, at this time it is very important for us to ensure that we deliver EVERYTHING that the user wants or deliver NOTHING.

We are highly against the idea of deleting ANYTHING (even if it is inserted by us) in someone else's account (for obvious reasons ). Thus I am not sure delete is an option in lieu of Rollback.

I am slightly sirprised that this feature isnt provided ;) but I am new and maybe you have a point that its not required most of the time. But unfortunately it seems that this time we require the feature of rollback and commit.

Thanks for all the suggestions.I appreciate it.

Regards,

Milan

SuperfellSuperfell
It doesn't exist today, Apex Code gives you some of these abilities but not for chunks as large as 5000 rows.


External transaction control that spans multiple requests over the internet is just a deadlock nightmare waiting to happen, I don't expect that anyone is going to offer these kinds of capabilities in an internet hosted service.
SaurabhRawaneSaurabhRawane
Frnds wat abt the idea of using an UPSERT call instead or insert and update call...