locked
Child exceptions in MS CRM RRS feed

  • Question

  • Hello Folks...

    I have a question on the Exception handling in MS CRM. Below is my query 

    I have entity A and on A record creation  entity B record gets created.. On record B Creation.. entity C records gets created through plugin.

    Now, if any exception raises in C... OR if i throw a custom exception from plugin C, I need to catch that in the Plugin A ?? A is the Parent of B.. B is the Parent of C. Is that possible ? & how? 

    let me know if I'm clear.. 

    Thanks in advance :) 

    Vish

     

     


    Wednesday, July 5, 2017 10:57 AM

All replies

  • Try shared variable.

    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Friday, July 7, 2017 11:44 AM
  • Hello Viswanath,

    I believe it can't be done directly, on behalf of plugins execution pipeline (when records B is created, the execution of plugin of entity A is already done). However you can follow one of the approach's:

    If you need to catch the exception just for logging:

    You can create a custom entity that will keep track of every plugin execution and on the catch block of every plugin you can create a new record on the custom entity

    If you need to catch the exception to change the state of the parent record:

    In this case, I recommend 2 options:

    1) Move your code from CRM to an external service (You can create a WCF or API that your CRM Plugin will invoke asynchronously and so you can handle your flow manually, which means you can create record A, B, C, D and if record E throws an exception you can do whatever you want with records A,B,C,D and E

    2) On the catch block of your plugin, you can use the ParentId to change any property or execute any action of the parent record.

    Regards,

    Henrique Silvestre Souza

    Friday, July 7, 2017 3:26 PM