May 11, 2024

ConditionOperator "Contains" doesnt work

When retrieving data using RetrieveMultiple we use different condition operators apart from Equal which is the most used one. 

Anyway, I noticed Contains operator is not working. For example below code, though looks alright, will not work. Its disappoint error message is not helpful either.

   
var query = new QueryExpression("account")
{
    ColumnSet = new ColumnSet("accountid", "name"),
    Criteria = new FilterExpression(LogicalOperator.And),
    TopCount = 10
};
query.Criteria.AddCondition("so_groupname", ConditionOperator.Contains, "expolanka");
Solution is to you like key work instead of Contains which does the same. Anyway, one thing to keep in mind is you need to use % mark for the task your check for. Check below;
   
query.Criteria.AddCondition("so_groupname", ConditionOperator.Like, "%expolanka%");

No comments:

Post a Comment