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

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

  • Suggested answer
    Johao Larios Profile Picture
    1,795 on at
    RE: Error injecting Fetch XML through Java Script

    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

🌸 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... 220 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

#3
Sahra Profile Picture

Sahra 43

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans