Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Quick find queries with multiple filter nodes are not handled properly #506

Open
ehclark opened this issue Jun 8, 2020 · 1 comment
Open
Labels
Milestone

Comments

@ehclark
Copy link

ehclark commented Jun 8, 2020

Model driven apps generate FetchXML that looks like this for quick find queries:

<fetch version='1.0' output-format='xml-platform' mapping='logical' returntotalrecordcount='true' page='1' count='50' no-lock='false'>
	<entity name='account'>
		<attribute name='statecode'/>
		<attribute name='entityimage_url'/>
		<attribute name='parentaccountid'/>
		<attribute name='name'/>
		<attribute name='address1_city'/>
		<order attribute='name' descending='false'/>
		<filter type='and'>
			<condition attribute='ownerid' operator='eq-userid'/>
			<condition attribute='statecode' operator='eq' value='0'/>
		</filter>
		<attribute name='primarycontactid'/>
		<attribute name='telephone1'/>
		<attribute name='accountid'/>
		<link-entity alias='accountprimarycontactidcontactcontactid' name='contact' from='contactid' to='primarycontactid' link-type='outer' visible='false'>
			<attribute name='emailaddress1'/>
		</link-entity>
		<filter type='or' isquickfindfields='1'>
			<condition attribute='accountnumber' operator='like' value='aurora%'/>
			<condition attribute='emailaddress1' operator='like' value='aurora%'/>
			<condition attribute='telephone1' operator='like' value='aurora%'/>
			<condition attribute='telephone2' operator='like' value='aurora%'/>
			<condition attribute='name' operator='like' value='aurora%'/>
		</filter>
		<attribute name='accountid' rowaggregate='CountChildren' alias='HierarchyDataChildCount6dcd9e4c001441b09237d51a34853d55'/>
	</entity>
</fetch>

In Dynamics 365, this will match all account records that are: owned by the user AND are currently active AND match one of the quick find conditions. In FakeXrmEasy, this will match all account records that are owned by the user AND are currently active. FakeXrmEasy does not seem to apply the quick find criteria.

Here is a unit I would expect to pass, but does not:

        public void Test()
        {
            Account acct = new Account
            {
                Id = Guid.NewGuid(),
                Name = "My Account"
            };
            XrmFakedContext context = new XrmFakedContext();
            context.Initialize(new List<Entity> { acct });
            IOrganizationService org = context.GetOrganizationService();
            EntityCollection results = org.RetrieveMultiple(new FetchExpression(
                @"<fetch mapping='logical'>
	                <entity name='account'>
		                <attribute name='statecode'/>
		                <attribute name='name'/>
		                <filter type='and'>
			                <condition attribute='statecode' operator='eq' value='0'/>
		                </filter>
		                <filter type='or' isquickfindfields='1'>
			                <condition attribute='name' operator='like' value='nomatch%'/>
		                </filter>
	                </entity>
                </fetch>"));
            Assert.AreEqual(0, results.Entities.Count);
        }

Changing the order of the 2 filter nodes causes the test to pass, implying that FakeXrmEasy assumes an entity node can have only a single filter child and that the second filter type overwrites the first.

@ehclark ehclark changed the title Quick find queries and not handled properly Quick find queries with multiple filter nodes are not handled properly Jun 8, 2020
@jordimontana82
Copy link
Owner

Thanks a mill @ehclark for raising this, and @BetimBeja for issuing a PR almost immediately :)

I'm tagging this one as one of the PRs for review after the release of 2.x #504.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants