Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Web Api queries using fetchXml and aliases suddenly stopped working

Posted on by

Hi all,

We have some queries against the D365 v9.0 api that use fetchXml that have suddenly stopped working today or over the weekend without any code changes.  The fetchXml joins the Account table to itself using aliases, and the aliases are used in the '$select' portion of the api call as well, but today we're getting the error:
"Can not resolve the segment identifier 'aliasname.fieldname' in query option".  Anyone know what might be going on?  Was something changed on the back-end that would break this?

For example, the fetchXML may look something like this:

	
		
		
		
		
			
		
		
			
			
			
				
				
			
		
	


and the api call would look something like this:

https://xxx.dynamics.com/api/data/V9.0/accounts?$select=accountid,name,parent.name,parent.accountid,grandparent.name,grandparent.accountid&fetchXml=[data from above]

and it will fail saying:
"Can not resolve the segment identifier 'parent.name' in query option"

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Web Api queries using fetchXml and aliases suddenly stopped working

    Hi,

    Above fetchXML looks good because when i run this on FETCHXML Builder in XRMToolbox then it shows the proper value.

    Now regarding Odata query: odata query does not support multiple link entity as shown in below screenshot:

    pastedimage1635834691328v1.png

    So, instead of Odata query please use Xrm.WebAPI,retrieveMultipleRecords as shown below:
    pastedimage1635835079774v2.png
    Code:

    
    
    var fetchXml = "" 
      "" 
        "" 
        "" 
        "" 
        "" 
          "" 
        "" 
        "" 
          "" 
          "" 
          "" 
            "" 
            "" 
          "" 
        "" 
      "" 
    "";
    
    Xrm.WebApi.retrieveMultipleRecords("account", "?fetchXml=" fetchXml).then(
        function success(result) {
            for (var i = 0; i < result.entities.length; i  ) {
                console.log(result.entities[i]);
            }                    
    
            // perform additional operations on retrieved records
        },
        function (error) {
            console.log(error.message);
            // handle error conditions
        }
    );

    Hope this helps.

    Thanks,
    Pradeep.

    Please mark this as VERIFIED, if it helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans