Skip to main content

Notifications

Announcements

No record found.

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

  • johny_crm Profile Picture
    johny_crm 735 on at
    RE: Generate New GUID

    Thanks. I think I will go the SDK route

  • Hosk Profile Picture
    Hosk on at
    RE: Generate New GUID

    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.

  • Suggested answer
    Josh Thompson Profile Picture
    Josh Thompson 1,115 on at
    RE: Generate New GUID

    +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.

  • Verified answer
    Hosk Profile Picture
    Hosk on at
    RE: Generate New GUID

    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.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans