Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to retrieve data of another entity from the current entity?

(0) ShareShare
ReportReport
Posted on by

hi,

i have a requirement.I have 2 entities A and B.When i am working on B entity i want to retrieve the records from A entity.How can i retrieve using C#?

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: How to retrieve data of another entity from the current entity?

    Hi,

    You could use QueryExpression in C# to retrieve the records of an entity in Dynamics CRM.

    See: arunpotti.wordpress.com/.../retrieve-records-using-query-expression-c-sdk-in-crm/

    Hope this helps.

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: How to retrieve data of another entity from the current entity?

    If you have relationship between these entities, you can use retrieve (as you will have lookup) otherwise you can use retrieve multiple to get record.

    You can refer SDK : msdn.microsoft.com/.../gg328198.aspx

    Thanks

  • Suggested answer
    Alfredo Aristimuño Profile Picture
    135 on at
    RE: How to retrieve data of another entity from the current entity?

    If these entities have a relationship, you can use a quick view form without writing any code technet.microsoft.com/.../dn531145.aspx

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: How to retrieve data of another entity from the current entity?

    If there is a relationship between Entity A and Entity B, such that there is a lookup for example in Entity B that has the value of a record in Entity A, you can do a simple QueryByAttribute or QueryExpression.

               QueryByAttribute query = new QueryByAttribute();

               query.ColumnSet = new ColumnSet(true);

               query.EntityName = "new_entityb";

               query.AddAttributeValue("new_entityaid", entityAId); // This is a Guid

               RetrieveMultipleRequest request = new RetrieveMultipleRequest();

               request.Query = query;

               RetrieveMultipleResponse response = (RetrieveMultipleResponse)service.Execute(request);

               Entity results = (Entity)response.EntityCollection.Entities[0];

               try

               {

                   Guid lookupId = new Guid();

                   lookupId = results.Id;

                   return lookupId;

               }

               catch (FaultException<OrganizationServiceFault> ex)

               {

                   throw ex;

               }

    Hope this helps.

  • Suggested answer
    Kishor Kumar Profile Picture
    3,710 on at
    RE: How to retrieve data of another entity from the current entity?

    Hi Teja,

    Check this,

    congruentdynamics.blogspot.in/.../retrieve-linked-entity-data-using-query.html

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans