Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Merge Permission

(0) ShareShare
ReportReport
Posted on by 30

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?

  • q1938484 Profile Picture
    30 on at
    RE: Merge Permission

    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

  • Suggested answer
    Torrado Profile Picture
    1,270 on at
    RE: Merge Permission

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,259 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,988 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans