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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Using fetchXML and Link entity on a subgrid

(3) ShareShare
ReportReport
Posted on by 6
I'm trying to link a table with fetchXML to populate a subgrid but it seems to not work. here is the fetchXML i'm using in my javascript code for subgrid onload. I used the XRMtoolbox  to check the xml and I got the desired result.
 
 
 
 fetchXml =  "<fetch version='1' output-format='xml-platform' mapping='logical' distinct='true'>
                                               <entity name='c_dp'><attribute name='c_name'/>
                                                         <link-entity name='c_dt' from='c_relatedtoprogram' to='c_dtpid' link-type='inner'>  
                                                                        <filter type='and' ><condition attribute='c_name' operator='eq' value='"+ Name+"'/></filter>
                                                        </link-entity>
                                               </entity>
                          </fetch>";
                                             

                                                                 control.setFilterXml(fetchXml);
                                                                  control.refresh(); 
Categories:
I have the same question (0)
  • Suggested answer
    Inogic Profile Picture
    748 on at
    Hi,
     
    If your FetchXML works in XrmToolBox but not in the subgrid, make sure you’re setting it after the subgrid is loaded and using the correct control reference:
    Here’s an example:
    function onLoad(executionContext) {
        var formContext = executionContext.getFormContext();
        var subgrid = formContext.getControl("YOUR_SUBGRID_NAME");
     
        if (subgrid) {
            subgrid.addOnLoad(function () {
                var Name = formContext.getAttribute("c_name").getValue();
     
                var fetchXml = "<fetch mapping='logical' distinct='true'>" +
                    "<entity name='c_dp'><attribute name='c_name' />" +
                    "<link-entity name='c_dt' from='c_relatedtoprogram' to='c_dtpid' link-type='inner'>" +
                    "<filter><condition attribute='c_name' operator='eq' value='" + Name + "' /></filter>" +
                    "</link-entity></entity></fetch>";
     
                subgrid.setFilterXml(fetchXml);
                subgrid.refresh();
            });
        }
    }
    Notes:
    • Use an associated view subgrid — filters don’t apply to custom views.
    • Always call setFilterXml() after the subgrid has loaded.
    • Retrieve your field value inside addOnLoad.
    • Please checked table permission for both entities.
    • Use the browser console or F12 developer tools to debug and confirm your FetchXML works as expected inside console.
    Hope this helps!
     
    Thanks!
    Inogic

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 156

#2
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans