I have a plugin that triggers on update of a Contact in Dynamics,
If in my plugin i set a new Entity to (Entity)context.InputParameters["Target"] am i right in thinking this entity will now have all of the fields associated to the contact record? or does it only contain the fields that were updated?
When the context.InputParameters["Target"] is EntityReference i retrieve the contact fields i need based on the target.id
Example
public void Execute(IServiceProvider serviceProvider) {
// Get tracing service for debugging purposes
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Get the context of the message
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
// Confirm that we have a target and that the target is an entity
if (context.InputParameters.Contains("Target")) {
// Get the service to be used for reading/writing to Dynamics
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService dynamicsService = serviceFactory.CreateOrganizationService(context.UserId);
Entity entity;
if (context.InputParameters["Target"] is Entity) {
tracingService.Trace("Contact update plugin is triggerd - Target is Entity");
entity = (Entity)context.InputParameters["Target"];
}