Saturday, 9 January 2016

Plugin on Merge message in CRM

Hi,
 
Recently, we had a to write a plugin on merge message in CRM. We need to perform some activity based on merged records(Master and Subordinate).
 
Here is the C# code to get the Master and Subordinate entity reference in the plugin code.
 
if (pluginContext.InputParameters.Contains("Target") && pluginContext.InputParameters["Target"] is EntityReference)
{
       EntityReference entityReferenceMaster = (EntityReference)pluginContext.InputParameters["Target"];
       Guid guidSubOrdinate = (Guid)pluginContext.InputParameters["SubordinateId"];

       // Get Master record information. Specify the attributes which you want to retrieve
       Entity entMasterAccount = crmService.Retrieve("account", entityReferenceMaster.Id, new ColumnSet(new string[] {  }));

       // Get Subordinate record information. Specify the attributes which you want to retrieve
       Entity entOrphanAccount = crmService.Retrieve("account", guidSubOrdinate, new ColumnSet(new string[] { }));
}

Hope this helps

--
Happy CRM'ing
Gopinath

1 comment:

  1. Thank you very much for this post. I was looking exactly for this !!! Good work !!

    ReplyDelete