CRM 2011 Update Plug-in: Which Fields Changed?

Bvrce picture Bvrce · Mar 26, 2013 · Viewed 8.9k times · Source

How can it be determined in a synchronous plug-in which fields changed?
The plug-in is registered on update.
Something like an isDirty() in JavaScript:

// TODO: Implement your custom Plug-in business logic.
IOrganizationService service = localContext.OrganizationService;
Entity account = (Entity)localContext.PluginExecutionContext.InputParameters["Target"];
if (account.GetAttributeValue<String>("address1_latitude").isDirty())
{
    service.Create(new Lead { FirstName = "LOCATION CHANGED" }); // this is a stub
} 

Answer

TeaDrivenDev picture TeaDrivenDev · Mar 26, 2013

The attributes that are actually present in the Target are the ones that have changed. Unchanged attributes don't appear there.