FetchXMLBuilder icon indicating copy to clipboard operation
FetchXMLBuilder copied to clipboard

Generated QueryExpression from FetchXml breaks if pulling a field from link entity

Open surrealjam opened this issue 9 years ago • 2 comments

The following query expression is not valid:

// Instantiate QueryExpression QEcontact
var QEcontact = new QueryExpression("contact");

// Add columns to QEcontact.ColumnSet
QEcontact.ColumnSet.AddColumns("fullname", "telephone1", "contactid");
QEcontact.AddOrder("fullname", OrderType.Ascending);

// Add link-entity QEcontact_systemuser
var QEcontact_systemuser = QEcontact.AddLink("systemuser", "systemuserid", "createdby", JoinOperator.LeftOuter);
QEcontact_systemuser.EntityAlias = "a_92b8a9000846497cb93366ebb85f221f";

// Add columns to QEcontact_systemuser.Columns
QEcontact_systemuser.Columns.AddColumns("fullname");

This is generated from:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="telephone1" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <link-entity name="systemuser" from="systemuserid" to="createdby" visible="false" link-type="outer" alias="a_92b8a9000846497cb93366ebb85f221f">
      <attribute name="fullname" />
    </link-entity>
  </entity>
</fetch>

Error is:

'Contact' entity doesn't contain attribute with Name = 'systemuserid'. 

The link entity from/to fields seem to have got mixed up.

surrealjam avatar Jan 25 '16 12:01 surrealjam

I guess #81 is not entirely solved, after all... Will have a look at this.

rappen avatar Jan 25 '16 14:01 rappen

Looks like this is still an issue.

mittapallikiran avatar Mar 16 '17 22:03 mittapallikiran

Works since...

rappen avatar Feb 06 '23 19:02 rappen