2

I'm using Microsoft's CRM software (4.0) and I'm trying to build a query expression. It works fine with querying only String values, but now I need to include a field that is of type CRMBoolean. I should also mention I'm querying custom entities.

So previously, in my query I would only search by a few fields, but they were all of type String. Now I need to add another ConditionExpression for a CRMBoolean. The type of custom entity I'm searching for has a field called "Condition" - which will either have a value of "true" or "false". In CRM the attribute is defined as a bit, but I didn't think that would make a difference.

Here is my code I'm trying to use to find records that have a condition of "true":

oCondition = New ConditionExpression()
oCondition.AttributeName = "myEntity_condition"
oCondition.Operator = ConditionOperator.Like

Dim bool As New CrmBoolean
bool.Value = True
oCondition.Values = New Object() {bool}

listConditions.Add(oCondition)

I don't get an error, but nothing really happens. The number of records that is returned never changes one way or another. Has anyone done this before?

Thanks in advance!

Matt
  • 4,656
  • 1
  • 22
  • 32
lhan
  • 4,585
  • 11
  • 60
  • 105

2 Answers2

2

I don't know how the like operator is suppose to behave on a boolean. I wonder if its being ignored. Try ConditionOperator.Equal.

John Hoven
  • 4,085
  • 2
  • 28
  • 32
  • yup, it needed to be "Equal" instead of "like" - I'm not sure why I had that there in the first place... oh well. Thanks for the help!! – lhan May 02 '11 at 17:19
2

Instead of putting a CrmBoolean object in the oCondition.Values array, just put a regular true/false boolean. I would also concur with benjynito on changing it to ConditionOperator.Equals instead of Like.

Matt
  • 4,656
  • 1
  • 22
  • 32
  • Wow, I even checked that to make sure he wasn't using CrmBoolean... Mondays. Must have just saw "bool" and went to the next line. – John Hoven May 02 '11 at 18:47