Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans