Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Primary field in custom entity

Posted on by 267

when we create custom entity, "name" field as a parimary field it creates with data type "single line text".
but i can also create new field like if i have "WorkShop" as an entity, i can create "WorkShopID" with data type "Parimary Key"

so my questions are following.

1) what is the difference between "name" field as a parimary field and "WorkShopID" with data type "Parimary Key" ?
2) Internally, D365 will create relationship with other entities with "name" field or with "WorkShopID"
3) Actually my confustion is: if "WorkShopID" is my primary key then this field should be displayed on the second tab "Primary Field" when i click entity name in components list in customization.

Thank yo in advance.

*This post is locked for comments

  • Verified answer
    Arpit Shrivastava Profile Picture
    Arpit Shrivastava 7,518 User Group Leader on at
    RE: Primary field in custom entity

    Hey Zaub,

    Answer of your 1st Ques - 

    First, Let me tell you the difference between Primary Field and Primary Key.

    Primary Field
    Specifies the name of the attribute that is the primary field for the entity.

    Primary Key
    Specifies the name of the attribute primary key for the entity. The primary key for a CRM Entity is the Globally Unique Identifier ( GUID ) that CRM uses to reference everything within the CRM system.

    Example:

    The Primary Key for account is accountid.
    The Primary Field for account is name.

    All Microsoft dynamics entities has unique identifier known as GUID, which we call as Primary Key of a particular record and it will always be there for each entity. You cannot create your custom Primary Key, the Key you creates is actually an Alternate Key, not the Primary Key.

    Prior to Microsoft Dynamic CRM 2015 Update 1 the only way to identify the records in CRM was the record guid. Now with the introduction of the Alternate Keys in Dynamics CRM 2015 Update 1 we can use alternate keys to uniquely identify a record in CRM in place of the primary key (GUID).

    Alternate Keys are there to help you keep your records unique based on the other fields.

    For example:

    Inside Contact Entity you add a field to store the Aadhaar (the Indian Identification Number) and set it as Alternate Key, in this way you can't save two contacts with the same Aadhaar.

    Answer of your 2nd Ques - Dynamic CRM uses only Primary Field in order to make relationships with other entities.

    Answer of your 3rd Ques - No, it won't. Because you cannot replace the CRM default Primary Key. The custom Key you creates is the Alternative Keys as I explained earlier.

    Hope you get the understanding now.

    I would recommend you go through the following articles to get to know more about the Keys Concepts:

    https://www.inogic.com/blog/2015/04/more-ways-to-search-a-record-in-dynamics-crm-2015-update-1-alternate-keys/

    https://community.dynamics.com/crm/f/117/t/215343

    https://www.powerobjects.com/2015/08/21/utilizing-alternate-keys-in-dynamics-crm-integrations/

    https://blogs.msdn.microsoft.com/crm/2007/06/18/understanding-crm-metadata-primarykey-and-primaryfield/

    If my answer helped to resolve your issue, kindly verify it by clicking 'Yes'. It would be helpful to the other community members seeking to resolve a similar issue.



    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.in

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Primary field in custom entity

    Hi,

    1) When you create any entity internally one I'd and name field automatically create which basically identifier of an entity record. Name field is for read purpose or you can say its name of a record and I'd field which holds unique constraints to maintain referential integrity  or relationship.

    2) Relationship always create through I'd field .

    3) I'd field does not display in UI. It's always internal purpose. Let's say you have lookup of an entity so you can see the record name only in the lookup list . When you select any lookup value internally it's taking reference of the I'd.

    You can change the lookup view  and add additional field as well to display.

    Hope this helps.

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans