Plugin Execution Context on Form Load RRS feed

  • Question

  • Hi,

    I would like to share our experience during CRM development and would like to know the reason or any input on this crm behaviour.

    Its quite difficult to explain the issue but let me try to make it simple to understand.


    1) There are two plugins on opportunity, one is for create opportunity and other works on update of opportunity.
    2) Plugin on Create of opportunity was running under Admin user context whereas plugin on update of opportunity was running under normal CRM User 'John' (not a system admin) context.
    3) Both the plugins Create/Update reads the account record selected as potential customer on opportunity.

    1) We were getting an error on opportunity creation as 'SecLib::AccessCheckEx failed. Returned hr = -2147187962'
    2) This error was thrown by CRM after creating opportunity record in database and while loading opportunity form with saved details.  
    3) When we analysed the error message we found the issue related to privilages.
    4) Plugin on create of opportunity was running under system admin context so there was no issue with the privilages available with system admin. Whereas plugin registered on update of opportunity was running under John's context and John was not having access on account selected as potential customer.
    5) When we change the user context for update plugin to admin it works fine.

    1) Error thrown by CRM is very obvious, but this error should have been thrown by opportunity update plugin and that too on update event of opportunity. In this scenario we have triggered create message and error is getting displayed on form load (formtype = 2 (update)).
    2) Do crm reads the update plugin context information on page load (formtype = 2 (update)) even before actual event is triggers?

    Any inputs will be highly appreciated!

    Vinayak Chavan

    Tuesday, December 31, 2013 6:33 AM

All replies

  • CRM can run additional (hidden) updates on the opportunity entity, which could be the cause of the update plugin firing. The main reason for these additional updates is if the isrevenuesystemcalculated field is set to 'true' - if so, I believe CRM will run an update on the page load to ensure the revenue is correctly calculated from the opportunityproduct records.

    Do you get the same behaviour if the isrevenuesystemcalculated field is set to 'false' ? If the update does not fire, this would indicate that the isrevenuesystemcalculated field is relevant to this issue. I believe that the update will only affect a few fields (estimatedvalue, and maybe a few others). If your update plugin does not need to run on these changes, you could filter the fields on which the update plugin is triggered.

    What version of CRM are you using ? If it is CRM 2013, then AutoSave may also be relevant

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, January 3, 2014 12:16 PM
  • Hi, Thanks for your input.

    We did try to check if update plugin is getting executed by setting debugger. But it wasnt.

    Vinayak Chavan

    Monday, January 6, 2014 5:34 AM