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)

How to get parent record(s) on the base of record id and entity name in Dynamics CRM?

(0) ShareShare
ReportReport
Posted on by

Hi,

I have record id and entity name. I want to get all the parent records of the record id.

Example

Entity: contact, contactid: "8b4597d2-34c1-e711-810e-5065f38a9b90"

This contact used in 2 records of Lead.

Parent Entity: lead, 

Record1: 

     leadid: "6d0e63ef-34c1-e711-810e-5065f38a9b91"

     parentcontactid: "8b4597d2-34c1-e711-810e-5065f38a9b90"

Record2: 

     leadid: "178b9dc6-35c1-e711-810e-5065f38a9b99"

     parentcontactid: "8b4597d2-34c1-e711-810e-5065f38a9b90"

So, in above case Lead is parent entity and I need both record of lead entity. If contact is assigned to any other entity i.e account, it must list all 3 records(2 of lead and 1 of account).

I am using HTML webresource. I can call using WebAPI.

Please suggest.

I event can't get list of entity which are in relationship with Account. Please suggest

Issue-in-get-parent-id.png

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    First to clarify one thing. If you have a lookup on the lead entity to the contact entity, the parent record is the contact, and the child record is lead.

    Your relationship is basically: Account -> Contact(s) -> Lead(s)

    You can use a webapi to do a retrievemultiple on the contacts, and for each contact to a retrieve multiple on leads so that you get the results that you are looking.

    Hope this helps.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Chhaya,

    There is no straight forward way to retrieve all the related record of an entity in a signle call. You need to list out the entities which has a lookup to contact and the schema name of the lookup. As in this, you identified contact is related to lead using parentcontactid and account using primarycontactid. Similarly you need to list out all the other entities.

    Once you have the list, you need to retrieve the related entity (i.e. lead, accounts...) separately using the RetrieveMultiple WEB API message.

    You can refere this to find the WEb API queries-

    community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records

    Hope this helps

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    One more thing.

    If you decide to use webapi, there are a variety of libraries that are available to simplify the webapi calling process.

    You can refer to the following blog article:

    www.briteglobal.com/.../dynamics-365-webapi-library-comparison

  • Community Member Profile Picture
    on at

    Hi, I am already using SDKMetaData to get list of entity. I think it should provide list of entity which are in relationship whether it is in one to many or many to one. I have tried by SDK Metadata but didn't get. See screenshot in my question.

    Here is good example to get list such entities but it is in C#: stackoverflow.com/.../list-entity-relationships-in-dynamics-crm-2013-2015

    I need this using HTML webresource where I use API.

    Can you please suggest me?

  • Community Member Profile Picture
    on at

    I can perform through webapi once I know which entities are in relationship. Is there any way to get such list. i.e if I pass Account, it should provide me list of entity which are in relationship like this but in HTML:stackoverflow.com/.../list-entity-relationships-in-dynamics-crm-2013-2015

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