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)

Reading Sub Grid Records of an Entity in C# code

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I have an requirement to read list of associated records provided in the subGrid for an entity through C# code. the code may be Plugin or any console application. but the bottom line is to read the list of Records with their attributes for the Entities Subgrid. Can you please any one help me on this? I can found lot of articles in google for reading thru java script, not for plugin or c# code. please guide me on this.

Regards

Praba

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    Use the belwo code as referecence to get all the related records of an entity.THis sample code shows how to get all contacts of a account based on the company field

    var query1 = new QueryExpression { EntityName = "contact", ColumnSet = new ColumnSet("firstname", "lastname", "emailaddress1", "telephone1") };  //replace  "contact" with your subgrid entity name as repalce all attibute names 
    query.Criteria.AddCondition("parentcustomerid", ConditionOperator.Equal, "guidoftheparentaccount"); //replace parentcustomerid with parent entity name and guidoftheparentaccount with guid of the customer
    var response= service.RetrieveMultiple(query1);
    if(response!= null && response.Entities.Count>0)
    {
    foreach (var subgridrecord in response.Entities)
    {

    }
    }

  • Community Member Profile Picture
    on at

    Awesome, its worked perfectly for me.. Thanks a lot Chitra.. :) ;)

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