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 CRM (Archived)

Error when creating new entity

(1) ShareShare
ReportReport
Posted on by

After restoring a backup of production in test, I'm not able to create new entities anymore.

The error I get is "Exception when executing non-query: insert into [StatusMapBase]([StatusMapId], [ObjectTypeCode], [OrganizationId], [State], [Status], [IsDefault]) values ('71aefdfe-c43e-e611-80d7-00155d008881', 10113, '8f5c2216-b595-4652-9374-be0dd04de5f0', 0, 1, 1) Exception: System.Data.SqlClient.SqlException (0x80131904): Violation of UNIQUE KEY constraint 'UQ_StatusMap'. Cannot insert duplicate key in object 'dbo.StatusMapBase'. The duplicate key value is (10113, 0, 1)."

 

The new objecttype code should be 10114, but it looks like 10113 is regenerated again. 

Does anyone has a clue on how to solve this issue?

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    Have you checked if you can create an entity directly in production ? That will determine if the issue is with the production database, or if the issue occurred during the backup/restore/import process.

    If you can create an entity in production, I'd try doing the backup/restore/import process again for test.

    The only possible causes I can think of are:

    • If someone has made unsupported direct changes in the database
    • I'm not sure if the entity creation process is just one SQL transaction. If not, you may have got unlucky during the backup of production and completed the backup as an entity was being created, and so only got part of the metadata. Note that entity creation via importing a solution is done as one transaction, so this wouldn't apply if you only create entities in production via importing a solution

    One other thing to try is to export the default solution from production, and import it into a new organisation. This won't fix anything, but might give more information about what's wrong

  • Suggested answer
    Community Member Profile Picture
    on at

    Found the issue. Database contains field (NextCustomObjectTypeCode) in OrganizationBase table. Can't figure out why it was not in sync with the already created objecttypecodes, but this fixed the problem

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans