Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

How to get subgrid records of the record present in lookup field using plugin

(0) ShareShare
ReportReport
Posted on by 255

Hi All,

I am very new to to writing plugin codes . i nees to some help regarding accessing subgrid record.

following is the scenario.

Entity A: having lookp of Entity B as "Current Status"

Entity B: have subgrid of mails

i need to write plugin on create of entity A to extract the related records of "mails" of the record present in lookup(Current status) on Entity A

can anybody help

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at
    RE: How to get subgrid records of the record present in lookup field using plugin

    First of all try to get GUID of lookup record in ms crm plugin using below syntax:

    Guid EntityBId = EntityB.Attributes.Contains("lookuplogicalname") && EntityB.Attributes["lookuplogicalname"] != null ? EntityB.GetAttributeValue<EntityReference>("lookuplogicalname").Id : Guid.Empty;

    Then pass this GUID to either LINQ, fetchexpression or query expression to retrieve all related email's with entity B.

    Please refer below url for reference:

    csharp.hotexamples.com/.../php-fetchexpression-class-examples.html

  • T.I.A Profile Picture
    1,760 on at
    RE: How to get subgrid records of the record present in lookup field using plugin

    Here's are articles on images and queries

    Images:

    crmchap.co.uk/.../

    Querying:

    docs.microsoft.com/.../use-querybyattribute-class

    docs.microsoft.com/.../use-fetchxml-construct-query

  • Suggested answer
    T.I.A Profile Picture
    1,760 on at
    RE: How to get subgrid records of the record present in lookup field using plugin

    !. Get the ID of the lookup on Entity A. You can do this using the post image or query it.

    2. FetchExpression or QueryExpression (depending on the coding standard you're using on your project) to retrieve all mails where the lookup on those records in the ID of the lookup you retrieved from Entity A

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 95

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans