locked
Crm update an attribute on a post update event RRS feed

  • Question

  • Hi

    There is a plugin which fires on a case update event. Now I need to update an attribute from the plugin. My initital thought is it might result into a recursive loop. Please advice me with an example as in how to update an attribute from a plugin fired on a post update event.

    Many Thanks


    Vivek Pradhan

    Wednesday, November 27, 2013 5:00 PM

Answers

  • Hi,

    First thing you can control this to using filtered attributes, you can select specific fields while registering plugin to fire your update plugin and then plugin will run only when those specific fields will be updated.

    Second if first scenario is not possible you can use depth property to check and return like below

    if (context.Depth > 1) {

    return;

    }


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Wednesday, November 27, 2013 5:14 PM
    Moderator
  • Hello,

    You don't need to use pre-entity image specifically to update field only, you can simply do this by entity object that you can fetch from execution context or create new entity object. like below

    entityobject["yourfield"]=value;

    While registering your plugin you have option to use filtering attribute that can control execution of your plugin logic only when those specific fields changed.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by _Vikram Thursday, November 28, 2013 1:33 AM
    • Marked as answer by vivekprd Friday, November 29, 2013 10:23 AM
    Wednesday, November 27, 2013 5:28 PM
    Moderator

All replies

  • Hi,

    First thing you can control this to using filtered attributes, you can select specific fields while registering plugin to fire your update plugin and then plugin will run only when those specific fields will be updated.

    Second if first scenario is not possible you can use depth property to check and return like below

    if (context.Depth > 1) {

    return;

    }


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Wednesday, November 27, 2013 5:14 PM
    Moderator
  • Hi Mahender

    Could you also give me an example how you update the attribute? Do i need to use pre-entity images ?

    Regards


    Vivek Pradhan

    Wednesday, November 27, 2013 5:22 PM
  • Could you also elaborate on this

    "First thing you can control this to using filtered attributes, you can select specific fields while registering plugin to fire your update plugin and then plugin will run only when those specific fields will be updated."

    Thanks


    Vivek Pradhan

    Wednesday, November 27, 2013 5:24 PM
  • Hello,

    You don't need to use pre-entity image specifically to update field only, you can simply do this by entity object that you can fetch from execution context or create new entity object. like below

    entityobject["yourfield"]=value;

    While registering your plugin you have option to use filtering attribute that can control execution of your plugin logic only when those specific fields changed.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by _Vikram Thursday, November 28, 2013 1:33 AM
    • Marked as answer by vivekprd Friday, November 29, 2013 10:23 AM
    Wednesday, November 27, 2013 5:28 PM
    Moderator