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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Error injecting Fetch XML through Java Script

(0) ShareShare
ReportReport
Posted on by 35

Hello,

We are trying to retrieve and display records related to an entity that are based on third level relationship. What i mean is we have Entity A that is related to Entity B with 1:N relationship. We have Entity B related to Entity C with 1:N relationship and then we have Entity C related to Entity D with a N:N relationship. We are trying to display all Entity D records in the form for Entity A. We were able to do this in classic UI using Fetch XML injected through Java Script that was based on an advanced find view. However with UCI, this breaks. For some reason the link entities are removed from the injected Fetch XML.

This is JS code we are using:

function UpdatePaxGrid(executionContext) {
    var formContext = executionContext.getFormContext();
 
    var bookingNo = Xrm.Page.getAttribute('cts_name').getValue();
    var seasonSet = Xrm.Page.getAttribute('cts_season').getValue();
    var season = seasonSet[0].id;
    season = season.slice(1,-1);
    

 


    var fetchXml =  ""
      ""
      "  "
      "    "
      "    "
      "    "
      "    "
      "    "
      "      "
      "    "
      "    "
      "      "
      "        "
      "          "
      "            "
      "                 "
      "                 "
      "            "
      "          "
      "        "
      "      "
      "    "
      "  "
      "";;

 


 
   if (Xrm.Internal.isUci())
   {
       var paxSubGrid = formContext.getControl("BookingPassengerSubGrid");
       if(paxSubGrid == null)
       {
            setTimeout(function () { UpdatePaxGrid(executionContext); }, 2000);
            return;
       }

 

       paxSubGrid.setFilterXml(fetchXml);
       paxSubGrid.refresh();
    }
    else
    {    
        
       var paxSubGrid = formContext.getControl("BookingPassengerSubGrid");
       if(paxSubGrid == null)
       {
            setTimeout(function () { UpdatePaxGrid(executionContext); }, 2000);
            return;
       }
       paxSubGrid.getGrid().setParameter("fetchXml", fetchXml);
 
       //Refresh grid to show filtered records only.
       formContext.ui.controls.get("BookingPassengerSubGrid").refresh();
    }
}

However, this is the Fetch XML that is being injected one JS execution:

	
		
		
		
		
		
			
		
		
		
		
		
		
		
		
		
		
		
		
			
		
	

As you can see the link entities are stripped out. 

Any suggestions how do i fix this? Thanks in advance. 

Regards,

Nithin

I have the same question (0)
  • Suggested answer
    Johao Larios Profile Picture
    1,795 on at

    Hello,

    I would try using the webAPI fetchXML function as described below: docs.microsoft.com/.../retrieve-and-execute-predefined-queries

    I have used it a lot and is very useful, hope this helps you to resolve your problem

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Manoj - ManoVerse Profile Picture

Manoj - ManoVerse 131 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 91

#3
Chris1968 Profile Picture

Chris1968 20

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans