Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

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

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
    Pawar Pravin 5,227 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
    T.I.A 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
    T.I.A 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans