In a recent post, CRM 4.0 Plugins, I said I would post an example of a plug-in that handles entity merges. Here is that sample! :)
public class MergeHandler : IPlugin
{public MergeHandler (string unsecureConfig, string secureConfig)
{}
public void Execute(IPluginExecutionContext context)
{ try {if (context.MessageName == "Merge" &&
context.PrimaryEntityName == "account") { string targetCrmId = ((Moniker)context.InputParameters[ParameterName.Target]).Id.ToString(); string subOrdinateId = context.InputParameters[ParameterName.SubordinateId].ToString();}
}
catch (Exception ex) {throw new InvalidPluginExecutionException(ex.Message, ex);
}
}
It's actually a lot easier than I thought. It just took me awhile to understand what values were going to be passed into Execute method of the plug-in.
0 Responses to “CRM 4.0 Plug-ins: Handling Entity Merges“