locked
InvalidPluginExecutionException dialog does not show up - CRM 2011 RRS feed

  • Question

  • I have a Plugin on the Creation, Updating, and Deletion of the OpportunityProduct entity in the CRM 2011. I want to through exception on the success of some operations, means want to display dialog. It is working fine for Update and Delete. But it is not working fine for the Creation of OpportunityProduct, it is not throwing exception in the dialog. It is showing Exception: “An error has occurred, Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solution or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.” Message : Create Primary Entity : opportunityproduct Action: Pre-Operation Execution Mode: Synchronous
    Thursday, November 21, 2013 5:45 AM

All replies

  • Hi,

    As it can be seen in the error message mentioned above that its a PRE-OPERATION plugin, hence your plugin will be executed before the actual record is created.

    As per the Event Execution Pipeline, sequence of execution is

    Pre-Operation Plugin(if any) --> Platform Core Operation [CREATE] --> Post-Operation Plugin(if any)

    Hence ensure that the plugin code is not trying to access the current OpportunityProduct record which is not created yet. While in case of Update and Delete, the same logic will work because the current record exists and you can perform necessary operations on current record.

    Hope this helps.


    Ajay Chawla

    Thursday, November 21, 2013 6:05 AM
  • Thanks Ajay, No this is not a issue, if i just simply forcefully throw exception On the Create Message without doing anything, 
    
    it is still showing this exception "An error has occurred, Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solution or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support." in the same window, not opening my exception in the dialog box. 
    
    

    This is my code.

    if (QuoteEntity.Entities != null)

                           {

                               tracingService.Trace("Total Won Entities : " + QuoteEntity.Entities.Count);

                               if (QuoteEntity.Entities.Count > 0)

                               {

                                   throw new InvalidPluginExecutionException("Quote associated with this opportunity is already processed to AX. This Opportunity product cannot be modified.");

                               }

                           }

    it is working fine, and i have seen the value of  "Total Won Entities : = 1 " in the tracing.

    But when i am throwing exception forcefully it is not opening in the dialog it is opening in the same window with this exception:  “An error has occurred, Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solution or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support."

    Thursday, November 21, 2013 6:24 AM
  • Hi Qaisar,

    Please try adding a try{} catch(){} block and then throw the exception. This might work.

    Thanks


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful" Thank you, DT

    Thursday, November 21, 2013 7:21 AM
  • http://jacksdynamicscrm.blogspot.in/2013/07/when-to-utilise-different-plugin-types.html

    This blog can help you get more information about Pre-Operation and Pre-Validation.

    Hence there are two things that you need to look at.

    1. Does CRM Platform allow to generate custom exception on Pre-Operation of CREATE event?

    2. Try to register the plugin on Pre-Validation instead of Pre-Create.

    Hope this helps.


    Ajay Chawla

    Thursday, November 21, 2013 7:34 AM
  • Thanks, can you tell me please how i can check "Does CRM Platform allow to generate custom exception on Pre-Operation of CREATE event"?
    

    Friday, November 22, 2013 7:25 AM
  • Thanks Ajay,

    I have checked your mentioned things,

    1. Yes my CRM platform allow to generate custom exception on Pre-Operation of CREATE event,
    2. I have also tried to register the plugin on pre-Validation instead of Pre-Create.

    But my exception is still thrown in the same page not display in the dialog. i am really upset due to this Glitch, i really dont get the actual point why it is happening.

    Monday, November 25, 2013 4:49 AM
  • Hi,

    Did you try to debug your plugin code ?

    It's executing up to following InvalidPluginExecutionException line ?

    throw new InvalidPluginExecutionException("Quote associated with this opportunity is already processed to AX. This Opportunity product cannot be modified.");



    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !!!
    Vikram Singh. !!!  My Blog

    Monday, November 25, 2013 5:08 AM
  • Yes i have debug my plugin code throw tracing it is working properly, but when i throw new exception it doesn't open in the dialog it is opening in the same window with this exception "An error has occurred, Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solution or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support".
    Monday, November 25, 2013 5:13 AM