web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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?

I have the same question (0)
  • Suggested answer
    Torrado Profile Picture
    1,270 on at

    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.

  • q1938484 Profile Picture
    30 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 41

#2
Martin Dráb Profile Picture

Martin Dráb 36 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans