How does SharePoint store the CAML for a view's filter?
-
22-07-2019 - |
Question
I'm trying to create a CAML query for a list in SP.
I thought of using the Modify view pages to create a basic view including a filter, then use some code to examine the Query Prop of the SPView:
string t = dataList.Views["MyView"].Query;
But CAML in t does not contain any Where elements. Just the orderby
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
How does SharePoint store the CAML for view filters?
Solution
Weird.
Because if you examine built in list schema (for example tasks list schema you can find at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\TasksList\Tasks\schema.xml) there is Where clause in Query element:
<View>
*....*
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE">
</FieldRef>
</OrderBy>
<Where>
<Or>
<Neq>
<FieldRef Name="Status">
</FieldRef>
<Value Type="Text">$Resources:core,Tasks_Completed</Value>
</Neq>
<IsNull>
<FieldRef Name="Status">
</FieldRef>
</IsNull>
</Or>
</Where>
</Query>
</View>
Oh, you may try SPCamlViewer to examine your views.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow