locked
CRM 2011 Plugin Post Operation RRS feed

  • Question

  • We have registered a custom plugin on the create and update messages of the incident entity.

    It is registered in the post operation stage of the pipeline.

    Is it possible to change values of the current incident record in the post operation stage? i.e. Could we change a field value and still have the change reflected in the database?

    We have tried to use a retrieve and update on the current incident record but it causes a huge loop as our same plugin is called again and again.

    Have we gone about this in the wrong way and would it be better to recode the plugin in the pre-operation stage?

    Monday, November 14, 2011 3:33 PM

Answers

  • If you want to update fields of the current record you should ideally use pre-operation. If you are using post operation and for some reason need it to be there... you use the context.depth to break the loop. if depth > 1 it has been a recursive call do not update once again.

    HTH

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, November 14, 2011 3:47 PM

All replies

  • If you want to update fields of the current record you should ideally use pre-operation. If you are using post operation and for some reason need it to be there... you use the context.depth to break the loop. if depth > 1 it has been a recursive call do not update once again.

    HTH

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, November 14, 2011 3:47 PM
  • If you want to update fields of the current record you should ideally use pre-operation. If you are using post operation and for some reason need it to be there... you use the context.depth to break the loop. if depth > 1 it has been a recursive call do not update once again.

    HTH

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Thanks Sam.

    We have additional logic that creates records on other entities using the OrganisationService but we also need to update values on the current incident record. From what you are saying the best method to be able to manipulate the current target entity is pre-operation??

    Do you know if you can use early bound types to manipulate the target entity or do we have to use a late bound entity class??

    Many thanks.

     

    Monday, November 14, 2011 3:56 PM
  • Hi Steven

      Do this would end up in dead lock. You need handle in your for Infinite loop detection using CorrelationToken Class

     Which has Depth as one of its attribute , As suggested by Sam

    http://msdn.microsoft.com/en-us/library/bb930164.aspx

    Hope this helps

    Dkay

    --------------------------------------------------------------------------------
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

     

    • Proposed as answer by D kay Tuesday, November 22, 2011 6:19 AM
    Monday, November 14, 2011 4:04 PM

  • Hi Steven

    Did this help?

    Please make sure to mark as answer to the response that helped you get through. This will help others with similar problem identify the answer and also close this thread as resolved.

    Thanks

    Dk

    Wednesday, November 16, 2011 12:11 PM