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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Generate New GUID

(0) ShareShare
ReportReport
Posted on by 735

I am updating table LeadBase by inserting from a .net application. When inserting 1 record I have a GUID auto created as: “00000000-0000-0000-0000-000000000000”, when inserting another record I am getting a key constraint conflict. I believe this is due to the next record I am trying to add is trying to use GUID “LeadId” as “00000000-0000-0000-0000-000000000000”.

 

Is there a way using .Net, with a previously added GUID (leadId) to generate the next GUID “LeadId” as CRM would do via the user interface.

 

When inserting a record to LeadBase I am not passing a LeadId, but letting SQL chose this for me.

I'm Using CRM 2013 on Premise and SQL Server 2008R2

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Hosk Profile Picture
    on at

    Writing directly to the SQL database is unsupported by Microsoft. If you have problems later they will only offer you limited support.  I would recommend you do not do this.

    this blog explains why

    crmbusiness.wordpress.com/.../why-you-shouldnt-put-unsupported-customizations-in-microsoft-dynamics-crm

    If you use the Microsoft SDK to add new Leads then it will automatically add a new guid and ensure that the guid doesn't already exist in the database.

    www.microsoft.com/.../details.aspx

    The sdk has lots of examples to show you how to do it.

  • Suggested answer
    Josh Thompson Profile Picture
    1,115 on at

    +1 for Ben's response. Inserting directly to the tables is unsupported, there is an SDK that provides the functionality you are looking for and helps to black-box some of the functionality and enforce business rules, constraints, defaults etc. You can also try a tool like CozyRoc, Scribe or the Free CRM connector to accomplish this work, all are going to use the SDK. If you feel you absolutely must go direct to the database, know that it is unsupported and MS may not even provide limited support beyond a "remove the stuff you put in and then we'll look if there is still a problem".

    I do not believe the GUID is created by SQL as a default the same way an identity column is generated so you will need to ask SQL for a new guid, you do this by calling the NEWID() function which will generate a guid. Guid's are not necessarily sequential and I don't believe all zeroes is a valid guid either.

  • Hosk Profile Picture
    on at

    all zero's for a guid is blank Guid or the same as Guid.Empty().

    This would never work and even if it did you would only be able to add one

    GUID = Globally Unique Identifier.

    The questions you are asking, basically is the functionality that the CRM SDK does for you once you have created an authenticated connection to the CRM database.

  • johny_crm Profile Picture
    735 on at

    Thanks. I think I will go the SDK route

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans