1

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
        ....
    }
Bhav
  • 1,957
  • 7
  • 33
  • 66

1 Answers1

2

Try following:

if (localContext.PluginExecutionContext.ParentContext != null &&
localContext.PluginExecutionContext.ParentContext.MessageName == "Merge")
{
//When records are merged
}
else
{
//All other cases
}
Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13
  • Have you ever seen where the ParentContext.MessageName is the SAME as the current context.MessageName ? Idk what's going on with my Plugins... both are "Delete" inside of the Plugin that is triggered by Deletes that happen in a separate custom Action Plugin. – Don Cheadle Aug 24 '23 at 21:57