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
    Johao Larios 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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,317 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans