1

I have a sync plugin that triggers on Entity A, Update Post Operation event. I have another Async plugin that triggers on the same Entity A and on the Update Post Operation as well. These 2 plugins serve different purposes and they must be registered this way.

I have the execution order set as follows: Sync plugin 1 Async plugin 2

My question is if the Sync plugin triggers first and throw exception, does the Async plugin still triggers and what about if I switch them so the Async will have execution order 1 and the Sync execution order 2.

My goal is to rollback any update if any of these 2 plugins throw an exception.

Nick
  • 780
  • 2
  • 13
  • 33
  • You can't rollback the async plug-in if it throws and exception, if you really need to do this, on the async plug-in catch you need to implement a logic to undo the actions made by the two plug-ins. – Sxntk Nov 26 '15 at 13:33

1 Answers1

3

Only when the synchronous plugin pipeline finishes without errors, asynchronous plugins are triggered.

So, the answer to your question is: no.

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42
  • assuming that the plugins fire when the same attribute is updated. If the sync plugin runs on attribute1 filtered and the async plugins runs on atttribute2 filtered, the async plugin will be launched. But if we assume that he registered the update on all attributes then the async will not be triggered – Guido Preite Nov 25 '15 at 09:08
  • So if I have the execution order set as follows: Sync plugin 1 Async plugin 2 and the Sync plugin throws an exception then Async plugin will NOT trigger? – Nick Nov 25 '15 at 16:18
  • The execution order is: Pre-validations plug-ins -> Pre-operation plug-ins -> Main Transaction -> Post-Operation plug-ins | At the same time Async plug-ins -> Workflows – Sxntk Nov 26 '15 at 13:37
  • In my case the Sync plugin with execution order 1 is Post Operation and the Async plugin with execution order 2 is Post operation as well and both are registered on the same entity. In case the Sync plugin throws an error will the Async plugin trigger? – Nick Nov 26 '15 at 14:24
  • @GuidoPreite: I tested the scenario you described, registering PreValidate, PreOperate and Post Update steps on entity Contact, filtered on attribute JobTitle and an Async Update step on entity Contact, filtered on attribute Fax. Then I updated both fields on an existing contact record. When any synchronous plugin step threw an exception, the asynchronous step was never executed. So, I could not reproduce the behaviour you described (on CRM 2015 OnPremise with most recent updates). – Henk van Boeijen Nov 30 '15 at 12:47
  • @Nick: the execution order does not play a role between synchronous and asynchronous plugins. All that counts is that the synchronous plugin pipeline needs to finish without throwing exceptions. When the changes have been committed to the database the asynchronous plugins are triggered. – Henk van Boeijen Nov 30 '15 at 12:58
  • @HenkvanBoeijen maybe I didn't write clear, but in my example I mean that they are filtered and fired on different attributes. If in your example you update only the field connected to the async plugin, the sync plugin (filtered on a different attribute) will not be triggered at all, but the async will be executed. – Guido Preite Nov 30 '15 at 13:27
  • @GuidPreite: in that case we are in sync. :-) In your scenario the synchronous plugin is not triggered. Therefore the plugin pipeline finishes without errors and asynchronous plugins are indeed triggered (like I stated in my answer). – Henk van Boeijen Nov 30 '15 at 14:07