How To Access Master & Duplicate Record In Merge Operation Plugin

One comment

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!



Advertisements

1 comments on “How To Access Master & Duplicate Record In Merge Operation Plugin”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.