I'm trying to retrieve records that contain some optionsetvalue from multi option set pick list.
This line make my code fail:
int[] values = GetValues();
query.Criteria.AddCondition(new ConditionExpression(fieldName,
ConditionOperator.ContainValues, values);
When I put the values with a comma separator the code works:
query.Criteria.AddCondition(new ConditionExpression(fieldName,
ConditionOperator.ContainValues, 1,2,3);
Only problem is that the values are dyanamic so I can't do that. The only way I found so far to overcome it was this:
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
foreach (int value in values)
{
filter.AddCondition(new ConditionExpression(fieldName,
ConditionOperator.ContainValues, value));
}
query.Criteria.AddFilter(filter);
Just wondering if there is a better solution than this one?