How transaction works in Dynamics CRM Aysnc Plugin

Posted on Posted in MS CRM 2013, MS CRM 2015

We know that Sync plugin in CRM executes with in the pipeline’s transaction and if we need to cancel whole transaction we can throw an exception and whole transaction will roll back.

However in Async is a different story. What happens if we need to cancel a transaction in Asynchronous plugin in CRM? unfortunately whole transaction can not be cancelled however we can write some kind of code to delete/update record if we need to revert back changes.

Let’s look at an example, we have a Work Order entity, on creation of a Work Order record we want to run Async plugin which associated couple of N:N records i.e. websites to work order.

In above scenario we are running/initializing an other transaction and an exception occurs in our (2nd) transaction of creating/associating websites to work order record will roll back however work order record which was created will still exist (obviously it is a Async plugin so no pre-validation or pre-operation stage)