locked
The impact of Update a field with Same Value through SDK RRS feed

  • Question

  • Hi all,

    just wondering for the organizationservice.update(entityToUpdate) message, when we set the entityToUpdate field with the same value will this trigger an actual update of the field even if the value is the same?

    if so will it fire the plugin if we have update message on the field?

    Will it create audit history record if the auditing on the field is on?

    Is there a performance impact on the update?

    Thanks

    Tuesday, May 8, 2012 11:32 PM

Answers

  • As to whether it will trigger a plugin depends on whether the plugin is registered for Update AND whichever attributes you have populated prior to calling .Update()

    Put another way; the CRM considers every attribute that you have populated in an Entity record and for which you have executed an Update method to be dirty.  Such attributes will trigger plugins, create audit records regardless of whether the value has actually changed.

    At a minimum, there will be the performance impact of plugin instantiation and execution (exactly how severe the impact is depends on what your plugin does) and the creation of a possibly superfluous audit record.


    --pogo (pat) @ pogo69.wordpress.com

    • Proposed as answer by MubasherSharif Wednesday, May 9, 2012 7:47 AM
    • Marked as answer by kenwcp Wednesday, May 9, 2012 9:29 PM
    Wednesday, May 9, 2012 1:59 AM
  • If you are using the OrganizationService to update the entity, it will trigger the actual update of the field regardless whether the field value is the same or not.

    The preferred way is to use the CrmServiceContext. The CrmServiceContext is similar to the ServiceContext in LINQ where it will keep track of which fields that get updated. Hence, when you call CrmServiceContext.SaveChanges, it is smart enough to only update the fields that were changed.

    Hope this helps.


    Dimaz Pramudya, CRM Developer, CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

    Wednesday, May 9, 2012 8:30 PM

All replies

  • As to whether it will trigger a plugin depends on whether the plugin is registered for Update AND whichever attributes you have populated prior to calling .Update()

    Put another way; the CRM considers every attribute that you have populated in an Entity record and for which you have executed an Update method to be dirty.  Such attributes will trigger plugins, create audit records regardless of whether the value has actually changed.

    At a minimum, there will be the performance impact of plugin instantiation and execution (exactly how severe the impact is depends on what your plugin does) and the creation of a possibly superfluous audit record.


    --pogo (pat) @ pogo69.wordpress.com

    • Proposed as answer by MubasherSharif Wednesday, May 9, 2012 7:47 AM
    • Marked as answer by kenwcp Wednesday, May 9, 2012 9:29 PM
    Wednesday, May 9, 2012 1:59 AM
  • The system is not smart enough to figure out that the old value is the same as the new one, so it will not discard your update and it will execute it, write to database, trigger plugins/workflows, etc. Even if the value did not actually change.

    However, if you do this through the application, the form is smart enough to figure out that the value did not change and the attribute will not be submitted.


    Gonzalo | gonzaloruizcrm.blogspot.com

    Wednesday, May 9, 2012 8:12 PM
    Moderator
  • If you are using the OrganizationService to update the entity, it will trigger the actual update of the field regardless whether the field value is the same or not.

    The preferred way is to use the CrmServiceContext. The CrmServiceContext is similar to the ServiceContext in LINQ where it will keep track of which fields that get updated. Hence, when you call CrmServiceContext.SaveChanges, it is smart enough to only update the fields that were changed.

    Hope this helps.


    Dimaz Pramudya, CRM Developer, CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

    Wednesday, May 9, 2012 8:30 PM