martedì 8 maggio 2012 23:32
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?
Tutte le risposte
mercoledì 9 maggio 2012 01:59
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
mercoledì 9 maggio 2012 20:12Moderatore
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
mercoledì 9 maggio 2012 20:30
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