Announcements
How I can prevent merging records in CRM Dynamics?
I know there is a merge permission that can be removed from security role, but it works only for existing records for example if I already have 2 contacts in CRM and I made an update to one of the record then duplicate detection message will pop up and if user click 'Merge' then security message will be presented to user preventing them from merging contacts.However, if user will create a new contact then permission message is not presented and user can merge contacts. How to completely disable merging?
I don't think I can write such plugin because when I'm creating a new record (not commited to database yet), and after I click save the merge popup window appears, however the custom message is ignored (not showing), so I think in this case the plugin is looking for context.MessageName == "create" instead of "merge", am I doing something wrong?
public void Execute(IServiceProvider serviceProvider) { try { IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity entity = (Entity)context.InputParameters["Target"]; if (entity.LogicalName == "contact" && context.MessageName.Equals("merge", StringComparison.InvariantCultureIgnoreCase)) { throw new InvalidPluginExecutionException("You can't merge!"); } } } catch (InvalidPluginExecutionException e) { // catch exception throw new InvalidPluginExecutionException("An error has occurred: " e.Message); } }
Plugin is registered on Create and Merge as PreOperation
Hello,
you can write a Plug-In, triggering on Merge message.
Please refer to this thread: community.dynamics.com/.../791295
Hope this helps you.
Please mark the answer as verified if helpful. That will help others in future.
André Arnaud de Cal...
294,259
Super User 2025 Season 1
Martin Dráb
232,988
Most Valuable Professional
nmaenpaa
101,158
Moderator