When you query a Lookup field using CAML by default it will be executed for matching the text of lookup that is not desired in many cases like my.
<Query>
<Where>
<Eq>
<FieldRef Name="LookupFieldName" />
<Value Type="Lookup">1</Value>
</Eq>
</Where>
</Query>
We need to just set a property "LookupId" to true in FieldRef Tag like the following
<Query>
<Where>
<Eq>
<FieldRef Name="LookupFieldName" LookupId="True" />
<Value Type="Lookup">1</Value>
</Eq>
</Where>
</Query>
This will instruct the CAML engine to use the value property of lookup to execute the match.
No comments:
Post a Comment