CAML: Filter URL field on description (not on URL)
-
16-10-2019 - |
Question
I have a list with an URL-field. Nothing special, just the OOTB Hyperlink-field.
I want to execute a CAML-query that selects items with a certain value in the description part of the URL-field.
CAML
<Query>
<Where>
<Contains>
<FieldRef Name="URL" />
<Value Type="URL">text</Value>
</Contains>
</Where>
</Query>
Result Only items with 'text' in de url part are selected, if a item has 'text' in the description part it is not selected.
How do i select items based the description of the URL?
Solution
I'm pretty sure you won't be able to do this with a CAML query. This is because for 'complex' fields which store multiple values, only the 'default' value is available to query - by this I mean what would be available when SPField.GetFieldValueAsText() is called.
This would mean the only way to 'query' like this is to iterate through the items in the list.