Properties "ServerUrl" (server Relative Url) and "EncodedAbsUrl" (Encoded Absolute Url) cannot be used since the field values are of type "Computed" and SPSiteDataQuery does not filter based on "Computed" field values (there are some workarounds for some computed fields as well)
So I started looking into "FileRef" (URL Path) and "FileDirRef" (Path) for filtering. It seems to be working for me.
For a particular SPFile/SPListItem the above field values would give the exact location of the item.the values would look similar like below:
Publishing Content Types:
FileDirRef: SubSite1/SubSite12/PagesFileRef: SubSite1/SubSite12/Pages/default.aspx
Non-Publishing Content Types: (normal SPListItems)
FileDirRef: SubSite1/SubSite12/Lists/{ListRootFolderUrl}FileRef: SubSite1/SubSite12/Lists/{ListRootFolderUrl}/{ItemName}
Using the above field values and with proper CAML filter xml, items can be filtered from multiple webs.
In my case I was querying against non-publishing content types. So I was applying ContentTypeId filter primarily to filter based on content type. Above that, I was applying filters for "FileRef" values to get the items from multiple webs.
Sample CAML Query would look like this:
(The first one with value "Lists" is to filter the items in the root web)
NOTE: If you are using just "SubSite1/SubSite12" to filter on the items, it would include the sub webs as well. Include the "/Lists" or "/Pages" at the end of web relative url to restrict to a single site.
If you have any questions, please add a comment.
Thanks
Senthil S
No comments:
Post a Comment