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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Using fetchXML and Link entity on a subgrid

(1) ShareShare
ReportReport
Posted on by 2
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
    657 on at
    Using fetchXML and Link entity on a subgrid
    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

Responsible AI policies

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

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 83 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 57 Most Valuable Professional

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 52 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans