0
votes

I have used the CRM 2011 SDK tool to generate classes for early-bound entities. My requirement consists of a Debit-Credit scenario. Therefore if one create object fails, the other must be rolled back.

I cannot find information on whether the method above, performs the operation in a transaction.

Can anyone confirm?

Thank you

1

1 Answers

1
votes

Depends how you are executing the create calls.

Externally, e.g. from a console application. Then no it doesn't. The ability to make a transaction call from an external application was introduced in CRM 2015/2016.

Sample: Execute multiple requests in transaction

Microsoft Dynamics 365 (online & on-premises) support batching of requests into a single web service method call. Each request in the batch is executed as part of a single database transaction. Failure of any request to complete successfully causes a rollback of any completed requests and no further processing is performed on requests not yet executed.

If you are executing inside of a plugin, then your create calls may be included in a transaction, dependent on the registration of your plugin.

Inclusion in Database Transactions

Plug-ins may or may not execute within the database transaction of the Microsoft Dynamics CRM platform. Whether a plug-in is part of the transaction is dependent on how the message request is processed by the pipeline. You can check if the plug-in is executing in-transaction by reading the IsInTransaction property inherited by IPluginExecutionContext that is passed to the plug-in. If a plug-in is executing in the database transaction and allows an exception to be passed back to the platform, the entire transaction will be rolled back. Stages 20 and 40 are guaranteed to be part of the database transaction while stage 10 and 50 may be part of the transaction.

Any registered plug-in that executes during the database transaction and that passes an exception back to the platform cancels the core operation. This results in a rollback of the core operation. In addition, any pre-event or post event registered plug-ins that have not yet executed and any workflow that is triggered by the same event that the plug-in was registered for will not execute.