I need to query an OptionSetValue
field to find active records according to a query done based on a specific Id. However, each time the query below executes I get the following error:
the type with data contract name optionsetvalue is not expected
How do I include an OptionSetValue
in the Values
attribute of a QueryExpression
Condition
?
queryEx = new QueryExpression
{
EntityName = "account",
ColumnSet = new ColumnSet(true),
Criteria =
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "neu_id",
Operator = ConditionOperator.Equal,
Values = {agency.ReferenceNumber}
},
new ConditionExpression
{
AttributeName = "neu_appointmentstatus",
Operator = ConditionOperator.Equal,
Values = {new OptionSetValue(279660000)}
}
}
}
};
EntityCollection collection = _client.RetrieveMultiple(queryEx);
In your condition you need to set the integer value of the optionset. So the code will be:
new ConditionExpression
{
AttributeName = "neu_appointmentstatus",
Operator = ConditionOperator.Equal,
Values = 279660000
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With