[Fix]-A record with these values already exists. A duplicate record cannot be created. Select one or more unique values and try again…and it’s consequenes..

Hi,

Recently we faced an issue while deploying solution to other environment from Dev..getting below error in Dynamics 365 On premise 8.2 version..

A record with these values already exists. A duplicate record cannot be created. Select one or more unique values and try again.

This could be due to below reasons..

1. One entity has two CustomControlDefaultConfigs

Like this

We tried to delete one of the duplicated CustomControlDefaultConfig (randomly). This works in some cases.

2. Entity with unique  CustomControlDefaultConfigid, but solution import crashes with error customcontroldefaultconfig With Id = d3226572-022c-e611-80e6-00155dc26410 Does Not Exist. The solution contains only one CustomControlDefaultConfig for this entity

<CustomControlDefaultConfigs>

<CustomControlDefaultConfig>

<PrimaryEntityTypeCode>10084</PrimaryEntityTypeCode>

<CustomControlDefaultConfigId>{bd771d8c-2cd6-e511-80d4-00155d0e4417}</CustomControlDefaultConfigId>

<ControlDescriptionXML>

<controlDescriptions />

</ControlDescriptionXML>

<IntroducedVersion>1.0</IntroducedVersion>

</CustomControlDefaultConfig>

</CustomControlDefaultConfigs>

This could be due to corrupt config setting as in our case.

Fix:

Delete the CustomControlDefaultConfigId present in the entity which is creating the issue, open the Customizations.xml in the solution and delete the highlighted ID.CaptureFor this use XRM Toolbox Bulk Delete tool to delete this ID as below, as this can’t be done using UI.

Capture1

To Delete a record we would we would use Bulk Delete Tool

Capture2

Capture3

Here is fetch XML to be used and replace the below highlighted ID in green with the ID from the customizations.xml

<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false”> <entity name=”customcontroldefaultconfig”> <filter type=”and”> <condition attribute=”customcontroldefaultconfigid” operator=”eq” value=”{a88b6a06-3f20-e811-9661-00155d00a048}” /> </filter>

</entity>

</fetch>

You can use Fetch XML Tester to verify if the record exists and after delete again you can run to verify if record got deleted..

Once record is deleted, try import the same solution again and it should work.

This works so that the solution from Dev would be imported to other environment but the Publish Customizations fails on import, you might encounter below issues.. when publishing..

  • Getting Dependency Calculation There was an error calculating dependencies for this component. Missing component id {0}
  • Failure trying to associate it with CustomControlDefaultConfig

Reason:

If there is any orphan record exists in “CustomControlDefaultConfigBase” table in the target environment it would cause solution import failure or ‘Publish Customizations’ error.

Fix:

CRM On-Premise

  • Check if any orphan records in CustomControlDefaultConfigBase tabel. (Use below queries)
    • SELECT * FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)
  • Note: before continuing, a backup database is recommended.
  • Delete from the Target environment the CustomControlDefaultConfig records with orphaned Object Type Codes:
    • DELETE FROM CustomControlDefaultConfigBase WHERE PrimaryEntityTypeCode NOT IN (SELECT ObjectTypeCode FROM Entity)

Prevention Tip:

  • If you are adding an entity to your solution, always add ‘Primary key’ field
    • In the source environment open the Solution being imported
    • Open each Entity and expand Fields
    • Make sure that every entity has its “Primary Key” added to the solution.

solution-add-primary-key-field-of-entity

Hope this helps..

Cheers,

PMDY

Advertisement

Author: Pavan Mani Deep Y

Technology geek who loves sharing my leanings, quick tips and new features on Dynamics 365 & related tools, technologies. An Azure IOT Enthusiast....

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 )

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

ECELLORS CRM Blog

Sharing thoughts and challenges on Power Platform & Azure along with respective solutions put together...

SharePains by Microsoft MVP Pieter Veenstra

Microsoft 365, Power Platform, SharePoint, Teams, Azure and Dynamics

D365 Demystified

A closer look at Microsoft Dynamics 365.

Vicky Rodgers - Microsoft Dynamics 365

Everything Microsoft Dynamics 365 for Customer Engagement

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

Microsoft Dynamics 365 UK MCT

All about Microsoft Dynamics 365

High Voltages

Arduino | ESP | Raspberry pi | IoT

Mihail's space

Just another WordPress.com site

Arun Potti's MS CRM blog

Microsoft Dynamics CRM

Sander van de Velde

Microsoft MVP Azure | IoT Platform Architect | Speaker about IoT | Let me add some value

Power Platform Blog

Author : Dharanidharan Balasubramaniam

That API Guy

Making the world a better place one PowerApp/Flow at a time!

Dynamics Back Page

Tips, Tricks, and General Musings on Dynamics 365 (CRM), the Power Platform, Power Apps, Power Automate, Power BI and related technologies

Azure Integration services for Dynamics 365

Azure Integration services for Dynamics 365 Unified Operations, Logic Apps, Azure Functions, REST

Power Maverick

Incredible journey into #Dynamics365, #CDS, #PowerApps #Azure and all good stuff that #Microsoft releases

Unleashing CRM

My Technical Thoughts about Microsoft Dynamics CRM- Unleashed

Srikanth Alluri

My experiences in & around Power Platform + Azure

Debajit's Power Apps & Dynamics 365 Blog

All about Power Apps & Dynamics

Rajeev Pentyala - Microsoft Power Platform

Sharing my knowledge on Power Platform, Dynamics 365, Azure & .Net Stack

Bansal Blogs - Dynamics 365, PowerApps, Microsoft Flows, Power BI

Programming demands a lot more than simple mastery in tools and technologies

%d bloggers like this: