CRM 4.0 Plug-ins: Handling Entity Merges

written by Ryan Rinaldi on Wednesday, November 12 2008

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.

Similar Posts

  1. CRM 4.0 Plugins
  2. PDC2008: Reflections
  3. vCard Code

Post a comment

Options:

Size

Colors