"does not contain" in CAML?

In CAML, I can query SharePoint lists by using the "Contains" element, but there is no "does not contain" -item I can use.

So what is the best way to get elements that don't contain a string? Is there a better way than going through each element?

+7
source share
5 answers

The same restriction applies to BeginWith. Unfortunately, I do not know any good solution. What could you do: Contains-Query, iterates over each element and gets the identifiers, and then makes another big query for "NotEqual ID 1 or NotEqual 2 ID or NotEqual 3 ......" Since the identifier is indexed as far as I know , this should have less impact on the database, but it still smells a lot.

For a small list, this does not matter; for large lists, I would use SQL Server Profiler to find out what these consequences are.

+4
source

So what is the best way to get items that don't contain a string?

Try using a calculated column to reflect the search value by creating the opposite value.

, , IsCritical. "/"

=ISNUMBER(FIND("Critical"), [Title])

CAML

<Query>
<Where>
   <Eq>
     <FieldRef Name='IsCritical'/>
     <Value Type='Boolean'>0</Value>
   </Eq>
</Where>
</Query>

0 " ". , CAML "Not Containts", , , .

CAML MSDN

+3

'Contains' 'BeginsWith' . , Sharepoint caml , , .

, , , , , #. , 100 , 1 , .

0

@drax: let the CAML hope go away - period. This is by far one of the worst aspects of current SP programming.

0
source

TRy Not Includes

<NotIncludes>
<FieldRef Name='FileLeafRef' />
                                            <Value Type='Text'>stringvalue</Value>
                                        </NotIncludes>
0
source

All Articles