Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Set key in Contact entity column emailaddress1

Posted on by 121

Hi everyone,

I'm tring to set emailaddress1 as key in my Contact entity. 

Previously I check and clean the column and there are no duplicate data.

I can't understand why, setting this field as key, the system job doesn't work.

On log I can see this error: 

The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ContactBase' and the index name 'ndx_for_entitykey_new_KEY_emailaddress1'. The duplicate key value is <redacted>.

AND

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 1505 (Fault Detail is equal to Exception details:
ErrorCode: 0x80044150
Message: Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 1505
TimeStamp: 2023-05-11T16:11:08.9014027Z
--
Exception details:
ErrorCode: 0x80040216
Message: Exception output:: System.Data.SqlClient.SqlException (0x80131904): The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ContactBase' and the index name 'ndx_for_entitykey_new_KEY_emailaddress1'. The duplicate key value is <redacted>.
at Microsoft.Crm.CrmDbConnection.HandleExecutionExceptionAbstract(Exception exception, String commandText, IDbConnection connection, IDbCommand command, IDbTransaction transaction, Boolean isOpen, Int32 commandTimeout, IConnectionRetryPolicy localRetryPolicy, Int32& retryCount)
at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetryAbstract[TResult](Func`1 executeMethod, IDbCommand command, IConnectionRetryPolicy retryPolicy)
at Microsoft.Crm.CrmDbConnection.<>c_...).

Can anyone help me?

Thanks in advance

S.I.

  • Verified answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Set key in Contact entity column emailaddress1

    Hi Silvia Innamorati

    Use SQL, for CDS in XRM tool-box. Run the below similar query, that will return the number of records that are still duplicates.

    SELECT emailaddress1  AS emailaddress,
    count(fullname) AS count
    FROM contact
    GROUP BY emailaddress1
    Order BY count DESC

    Fix these records. Now you are able to create a new key for emailaddress1  

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans