Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How can I know the foreign key which links up two entities?

Posted on by Microsoft Employee

How can I know the foreign key which links up two entities? I am now using CRM 2011. Thanks so much!!!!!

*This post is locked for comments

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: How can I know the foreign key which links up two entities?

    Hi Mary,

    You can check 1:N relationship in Setting->Customization->Entities->(Entity)->1:N Relationship.

    This will show you the linked entities.

    In CRM, the foreign key column is always the uniqueidentifier column for link entities. So you can find the same information in relationship details as well.

    What exactly are you trying to do? If you are trying to build fetchxml then this can be done in advance find of crm which automatically list down all the relationship.

    Thanks,

    PS

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I know the foreign key which links up two entities?

    Hello Mary in JavaScript on the form you can get the foreign key of a lookup by using the following javascript:

    Xrm.Page.getAttribute("yourlookupname").getValue()[0].id
  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How can I know the foreign key which links up two entities?

    You can retrieve data using Fetchxml

    Refer this:

    lakshmanindian.wordpress.com/.../retrieve-data-using-fetchxml-with-multiple-link-entities-in-crm-2011

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can I know the foreign key which links up two entities?

    Thanks for your answer! What if I would like to query the entities in lookup field? How can I find the foreign key? Thanks!

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How can I know the foreign key which links up two entities?

    Refer this also:

    community.dynamics.com/.../209749

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How can I know the foreign key which links up two entities?

    Refer this:

    stackoverflow.com/.../how-do-you-reference-a-one-to-many-relationship-in-crmservice

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans