web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    Kishor Kumar Profile Picture
    3,710 on at

    Hi Teja,

    Check this,

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

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

    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
    Alfredo Aristimuño Profile Picture
    135 on at

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

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    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
    Nithya Gopinath Profile Picture
    17,078 on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans