locked
Can we have two Service.Updates in a delete plugin RRS feed

  • Question

  • Hi,

    I have a delete plugin where I want to update two entities

    i.e I have two service.Update() statements in a Execute() method.

    But having these two service.update() methods in one execute Method fires a SQL Generic Error. But if I comment one of them either, things work fine.

    So is it the constraint in MS CRM 2011 that we cannot have two update methods in one Execute Method of a Delete?

    Is there any work around of this?

    Any help would be much appreciated !!!

    Thanks in advance

    Regards,

    Sachin

    Tuesday, June 26, 2012 4:51 PM

Answers

  • You could consider registering your plugin in a PreValidation or Asynchronous stage.


    Henk van Boeijen

    Tuesday, June 26, 2012 6:53 PM

All replies

  • Hello Sachin:

    In MS CRM 2011, two service.Update() in one execute will not work. It is not a limitation but logically it set the lock on the database. While one update is happening, lock is still there and it will be released only after execute will complete.

    So to do this, you have to use two separate execute methods. This is the only workaround I can suggest.


    If my suggestion helps you in solving your issue, kindly do me a great favor by marking it as correct answer. Thanks in advance "Saurabh Gupta, MS CRM 2011 Software Development Engineer"

    Tuesday, June 26, 2012 5:19 PM
  • Hi Saurabh,

    Thanks for your reply.

    Even firing two execute method's ( or firing two plugins ) on same Delete event of a entity gives the same error. I tried this earlier and then tried to merge it and execute in one Execute.

    Regards,

    Sachin

    Tuesday, June 26, 2012 5:24 PM
  • May we see your code?
    Tuesday, June 26, 2012 5:26 PM
  • Also, what stage have you registered the plugin step on ? This will affect the SQL transaction behaviour

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

    Tuesday, June 26, 2012 5:36 PM
    Moderator
  • Hi,

    I have registered them on the Pre-Operation of Delete Operation. 

    Regards,

    Sachin

    Tuesday, June 26, 2012 5:55 PM
  • You could consider registering your plugin in a PreValidation or Asynchronous stage.


    Henk van Boeijen

    Tuesday, June 26, 2012 6:53 PM
  • Hi,

    I registered them in PreValidation event and it worked !!!

    Thanks a lot & thanks everybody for responding to my question !!!

    Regards,

    Sachin

    Thursday, June 28, 2012 8:03 AM