CRM 2013 Plug-in on Opportunity Total Amount Change RRS feed

  • Question

  • Hi,

    I have few plug-ins written on opportunity product(Pre Create) and opportunity(post update), getting some SQL errors related to deadlocks. Below is what am trying to achieve in these plug-ins.

    Our Products are charged monthly and business want to track the revenue generated per annum at the opportunity level. So to achieve this, i have a plug-in on the opportunity entity which triggers when there is a change in the Total Amount field, multiplies it by 12 to set the Est Revenue and few other Revenue fields based on Est.Revenue, this Total amount is getting calculated by the CRM system when a new opportunity product is added.  The Total Amount is basically the sum of all the products Total.

    I also have a plug-in on the opportunity product to do some custom logic before the record is created which will pull some details from the opportunity and account and set few fields on the opportunity product.

    All works fine if i just add one opportunity product, but if i add multiple opp products, it breaks throwing SQL deadlock errors.

    I tried to change my plug-in on the opportunity also to pre-update of Total Amount, but for some reason it doesn't trigger at all, not sure what is the reason because I am not quite sure when CRM updates the Total Amount field when a new opp product is added.

    I found a link where he suggests to retry couple of times if there is Generic SQL errror, i do get this error few times, but not all the time saying Generic SQL error, i can put retry in all the places where am making a Service call either to retrieve/update, but i don't think it is a right option, any ideas?



    Regards Jeevan Please vote for me if you find the answer is useful.

    Thursday, August 20, 2015 9:58 AM