Friday, September 23, 2022

Create Filter Expression with AND & OR Condition in Model Driven Apps

Introduction:


In this Blog we Will see how to Use Filter Expression with Both And/Or Condition with Query Expression


Implementation Steps:

 

Consider a Scenario that I want to make Multiple Filter Condition with Both And/or Condition From Account Table Using Plugins

 

QueryExpression query = new QueryExpression("account");
query.ColumnSet.AddColumns("accountid");
FilterExpression filterAccount = new FilterExpression(LogicalOperator.Or);

FilterExpression filterName = new FilterExpression(LogicalOperator.And);
filterName.Conditions.Add(new ConditionExpression("NAME_LOGICALNAME", ConditionOperator.Equal, PASSYOURVALUEHERE));
filterName.Conditions.Add(new ConditionExpression("NAME_LOGICALNAME", ConditionOperator.Equal, PASSYOURVALUEHERE));

FilterExpression filterName2 = new FilterExpression(LogicalOperator.And);
filterName2.Conditions.Add(new ConditionExpression("NEWFIELD_LogicalName", ConditionOperator.Equal, id2));
filterName2.Conditions.Add(new ConditionExpression("NEWFIELD_LogicalName", ConditionOperator.Equal, id3));

filterAccount.AddFilter(filterName);
filterAccount.AddFilter(filterName2);

query.Criteria = filterAccount;

 

In the Above Example Am using Both And/OR Condition in FilterExpression with QueryExpression.

 

That's it :slightly_smiling_face:

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...