Sunday, May 6, 2018

Violation of PRIMARY KEY constraint 'I_65518FIELD' - Dynamics 365 for Finance & Operations LBD

Hi

Recently I had a Synch issue during my deployment on a Dynamics 365 FO LBD Implementation.

This is the error:

Violation of PRIMARY KEY constraint 'I_65518FIELD'. Cannot insert duplicate key in object 'dbo.SQLDICTIONARY'. The duplicate key value is (TABLEID, FIELDID, 1, 0).

It seems that already exist a field with the same FieldID!

With Microsoft Dynamics 365 FO I thought that issue like that doesn't happen anymore.

However, against the Business Database exist a table named TABLEFIELDIDTABLE that list for each table the fieldId values.

From my side I notice that some of my custom field ids present on that table was different than the Ids listed on the SqlDictionary table.

Really strange..

So, I decide to update the SQLDictionary table according with the Id values coming from the TABLEFIELDIDTABLE table.

Lastly, I restarted my deployment from the same failed step.
Take a look here in order to understand how to rerun a specific Step without to rerun the entire process.

The same issue could occur also on a Cloud Deployment, like on your Tier 1 or UAT Environment

That's it!

1 comment:

Simon Buxton said...

Hi Denis,

I wrote this script based on what you write:
select T.ID, T.NAME, S.FIELDID,
(SELECT TOP 1 Q.NAME from SQLDICTIONARY Q WHERE Q.TABLEID = T.TABLEID AND Q.FIELDID = 0) AS TableName
from TABLEFIELDIDTABLE T
JOIN SQLDICTIONARY S ON T.TABLEID = S.TABLEID AND T.NAME = s.NAME
WHERE S.FIELDID <> 0 AND S.FIELDID <> T.ID
ORDER BY T.TABLEID

This finds 767 records in my dev box, which doesn't appear to have SQL sync issues.

is this what you meant?

Cheers, Simon