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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

How to put And and OR filter type when RetrieveMultiple query is Fetch Expression

(0) ShareShare
ReportReport
Posted on by 15

Dear Experts,

Please advice how to filter CRM/Model Driven App Unified Client Interface View using below same query expression in RetrieveMultiple plugin when input parameter query is of type Fetch Expression:

FilterExpression filter = new FilterExpression(LogicalOperator.Or);

string[] sourceChannel = new string[] { "Central Bank", "AECB" };

FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));

FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));

FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression("reopeningcount", ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));

FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));

filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);

qe.Criteria.AddFilter(filter);

I tried below by taking help from Microsoft documentation as described here:

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/org-service/samples/modify-query-preoperation-stage

But I don't have any idea how to put And and OR filter type in below XML Document.

Any help or guidance would be appreciated a lot.

entityElement.Add(
new XElement("filter",
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value",
new XText("Central Bank")
),
new XElement("value",
new XText("AECB")
)
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);

I have the same question (0)
  • Esteban Coto Alfaro Profile Picture
    Microsoft Employee on at

    Hello, check this documentation that explain with code examples how to do an "AND"/"OR" operation: docs.microsoft.com/.../use-filterexpression-class

    Thanks!

    Community Support Team - Esteban

    If this Post helps, then please consider Accept as solution to help the other members find it more quickly.

  • Abdul Mannan786 Profile Picture
    15 on at

    Hello Esteban,

    You didn't get my question. I am not asking how to add filter expression with And and OR in query expression. I want to know how we can do it in XML doc when input paramter query is fetch expression which is the case when view is UCI.

  • Abdul Mannan786 Profile Picture
    15 on at

    I got the answer on stack overflow:

    stackoverflow.com/.../how-to-put-and-and-or-filter-type-when-retrievemultiple-query-is-fetch-expression

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 98 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans