web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    RE: FetchXML query with link entities giving error: Generic SQL error.

    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
    RE: FetchXML query with link entities giving error: Generic SQL error.

    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,626 on at
    RE: FetchXML query with link entities giving error: Generic SQL error.

    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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans