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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

FetchXML query with link entities giving error: Generic SQL error.

(0) ShareShare
ReportReport
Posted on by

Hi,

We have a fetchxml query which works one of our CRM instance while fails on another instance with error: Generic SQL error.

<fetch version="1.0" output-format="xml - platform" mapping="logical" distinct="False" top="1">
 <entity name="salesorderdetail">
  <attribute name ="salesorderdetailid"/>
  <link-entity name="gc_productkey" from="gc_orderlineitem" to="salesorderdetailid" alias="gc_productkey" link-type="inner">
  </link-entity>
  <link-entity name="salesorderdetail" from="salesorderdetailid" to="parentbundleid" alias="pdd" link-type="inner">
  </link-entity>
 </entity>
</fetch>

  • gc_orderlineitem is a text field on 'gc_productkey' entity which holds the GUID of salesorderdetail.

One more observation on the CRM instance where the query fails was that when we remove either of the link statements, query successfully gives results.

Note: Both are Dynamics 365 instances with same CRM version.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    Link entity works if you have relationship between two entities, i.e. lookup of one entity on another entity.

    In your case "gc_orderlineitem" is a text field if you make it lookup then it may solve your issue.

  • Community Member Profile Picture
    on at

    Hi,

    Thanks for reply.

    FetchXML works for fields even if they are not lookup. In the 'gc_orderlineitem' field we store the GUID of order line item.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    I would advice you to use one of the tool in XRMtoolbox called fetchxml builder to build the query and test the result.

    https://fxb.xrmtoolbox.com/

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans