如何查询SharePoint中使用某种内容类型的所有列表?
我有以下 CAML 查询:
<Where>
<And>
<Eq>
<FieldRef Name='PublishToSM' />
<Value Type='Boolean'>True</Value>
</Eq>
<IsNull>
<FieldRef Name='SMUpdateDate' />
</IsNull>
</And>
</Where>
我只有一种使用这些字段的内容类型。当我针对使用此内容类型的列表运行此查询时,一切正常。当我针对未正确安装的列表运行它时,它会抛出错误:一个或多个字段类型未正确安装。转到列表设置页面删除这些字段。
我希望能够搜索网站集中所有网站上的所有列表。这可以在不出错的情况下完成吗?
I have the following CAML query:
<Where>
<And>
<Eq>
<FieldRef Name='PublishToSM' />
<Value Type='Boolean'>True</Value>
</Eq>
<IsNull>
<FieldRef Name='SMUpdateDate' />
</IsNull>
</And>
</Where>
I have only one content type that uses these fields. When I run this query against a list that uses this content type everything works fine. When I run it against a List that does not it throws the error: One or more field types are not installed properly. Go to the list settings page to delete these fields.
I would like to be able to search all Lists on all websites in a site collection. Can this be done without erroring out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 SPSiteDataQuery,添加 where 子句以包含内容类型。即:
将
SPSiteDataQuery
的Scope
属性设置为 SiteCollection。通过设置Lists
属性,您还可以将搜索限制为文档库等。可以设置ViewFields
属性来限制检索的字段(即,而不是等效的)在项目字段上选择*
)Use SPSiteDataQuery, add a where clause to include the content type. i.e.:
Set the
SPSiteDataQuery
'sScope
property to SiteCollection. By setting theLists
property you can also limit the search to for instance document libraries etc. TheViewFields
property can be set to limit the fields retrieved (i.e. instead of the equivalent of aselect *
on the items's fields)