I've got a plugin that fires when a contact gets updated. This also gets fired when two contacts get merged. What's the easiest way to identify whether contacts have been merged within the PreContactUpdate plugin?
code:
protected void ExecutePreContactUpdate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
Entity contact = (Entity)localContext.PluginExecutionContext.InputParameters["Target"];
// check if contacts have been merged
....
}
Try following:
if (localContext.PluginExecutionContext.ParentContext != null &&
localContext.PluginExecutionContext.ParentContext.MessageName == "Merge")
{
//When records are merged
}
else
{
//All other cases
}