rappen / FetchXMLBuilder

FetchXML Builder for XrmToolBox and Microsoft Dynamics 365 / CRM
https://fetchxmlbuilder.com/
GNU General Public License v3.0
133 stars 55 forks source link

Bug: Issue using filter in linked entity. #972

Closed sabin-sharma closed 4 months ago

sabin-sharma commented 11 months ago

Scenario: Add the link entity and use the filter with two condition in the link entity.

Issue: If the condition's attribute exists in both the main entity and the link entity then it works fine. If the attribute is only in the link entity and does not exists in the main entity it throws error.

Error: 'Account' entity doesn't contain attribute with Name = 'new_exclude' and NameMapping = 'Logical'.

Example.

Say 'new_exclude' attribute exists in Contact table but not in Account and we would like to filter record based on the value of this attribute.

FetchXML that generates error.

<fetch>
  <entity name="account">
    <attribute name="name" />
    <link-entity name="contact" from="parentcustomerid" to="accountid" link-type="inner" alias="contact">
      <attribute name="fullname" />
      <filter>
        <condition attribute="statecode" operator="eq" value="0" />
        <condition attribute="new_exclude" operator="eq" value="1" />
      </filter>
    </link-entity>
  </entity>
</fetch>

In order to make above FetchXML work we have to add another filter as shown below.

<fetch>
  <entity name="account">
    <attribute name="name" />
    <link-entity name="contact" from="parentcustomerid" to="accountid" link-type="inner" alias="contact">
      <attribute name="fullname" />
      <filter>
        <condition attribute="statecode" operator="eq" value="0" />
      </filter>
      <filter>
        <condition attribute="new_exclude" operator="eq" value="1" />
      </filter>
    </link-entity>
  </entity>
</fetch>

rappen commented 9 months ago

I really can't reproduce your issue... I created this one, and there are no issues.

<fetch>
  <entity name='account'>
    <attribute name='name' />
    <link-entity name='contact' from='parentcustomerid' to='accountid' alias='contact'>
      <attribute name='fullname' />
      <filter>
        <condition attribute='lastname' operator='not-null' />
        <condition attribute='firstname' operator='not-null' />
      </filter>
    </link-entity>
  </entity>
</fetch>

Can you reproduce it now? Any more info for me?

rappen commented 4 months ago

No response. Closing this issue, please reopen if you have any feedback!