locked
Plugin Not Triggered RRS feed

  • Question

  • I have a workflow that is changing some fields of an entity record. I also have a plugin that gets fired whenever a record for that entity is being updated. All works just fine when I manually change a field and save the record (I have a breakpoint at the very beginning of the plugin where it stops). However, when I manually start the workflow, which changes the same fields, then the plugin does not get triggered. I can verify that the workflow indeed changed the record (F5 does not update but when I reopen it then I see the change. Also when I look in the workflow history of that record I can see both that it has completed and which fields were changed).

    Why does my plugin not get triggered when I modify fields through a workflow but it does trigger when I manually change the same field?

    Monday, October 8, 2012 6:23 AM

Answers

  • I think I figured it out. I did attach to w3wp. That worked fine when I made a manual change to the record because the plugin is registered to execute synchroniously. Now the workflow is executing asynchronously. I did expect that the plugin would still run under w3wp (which is for synchronous processes) even if the workflow runs asynchronously. However, this does not seem to be the case as when I attach to CrmAsyncServce then it triggers my breakpoint just fine. I guess it depend on what starts the chain and everything underneath will run on the same process.

    • Marked as answer by hfaun Monday, October 8, 2012 10:18 PM
    Monday, October 8, 2012 10:18 PM

All replies

  • Hi,

    are you performing some kind of check in the plugin concerning the Depth of the context? i.e.:

    if (context.Depth > 1)
    {
       return;
    }

    Where context = Plugin Execution Context.

    Greetings,

    Pavlos


    Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.

    Monday, October 8, 2012 6:31 AM
  • Pavlos, thanks for the quick reply. I saw another thread where somebody else had the same issue and it did not get triggered because of checking the depth (as you mentioned). However, I am not checking for that and I also have set my breakpoint at the very beginning of the plugin.
    Monday, October 8, 2012 6:38 AM
  • Here is a new interesting observation. When I change the execution mode to asynchronous then my plugin does not get triggered anymore even when changing a field manually. The field has indeed changed but the plugin did not get triggered. The workflow also execute asynchronously so we end up with the same behavior. But why does my plugin not get triggered when it's set to asynchronous?
    Monday, October 8, 2012 7:01 AM
  • I think I figured it out. I did attach to w3wp. That worked fine when I made a manual change to the record because the plugin is registered to execute synchroniously. Now the workflow is executing asynchronously. I did expect that the plugin would still run under w3wp (which is for synchronous processes) even if the workflow runs asynchronously. However, this does not seem to be the case as when I attach to CrmAsyncServce then it triggers my breakpoint just fine. I guess it depend on what starts the chain and everything underneath will run on the same process.

    • Marked as answer by hfaun Monday, October 8, 2012 10:18 PM
    Monday, October 8, 2012 10:18 PM