How To Access Master & Duplicate Record In Merge Operation Plugin

Here is a quick blog on how to access master & child records during a Merge operation in a plugin.

I recently had to develop a plugin where in I needed to do some manipulation with the records being merged.

You can access three entities in your plugin when a record is merged from Context.InputParameter : 

       1. SubordinateId – the duplicate record
       2. Target – the master record
       3. UpdateContent   – a temp entity contains the final attribute as outcome of the merge operation.


To Access them in the code simply do this:


Entity duplicate = context.InputParameters[“SubordinateId“]; // To access the duplicate record simply retrieve the attributes using service.retrieve and by proving the duplicate.Id.

EntityReference
target= (EntityReference)context.InputParameters[“Target“];

Entity
finalRecord = context.InputParameters[“UpdateContent“]; //To access the final record simply retrieve the attributes using service.retrieve and by proving the finalRecord.Id.

I hope it makes sense:
Cheers!



Advertisement