仅使用CAML检索一个Listitem

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了仅使用CAML检索一个Listitem相关的知识,希望对你有一定的参考价值。

我试着查询一个sharepoint列表。它应该只返回在URL中具有fieldproperty的Listitem:

var Reference= getParameterByName('FilterValue1'); //refers to the funcktion
 var queryString = "<View> <Query><Where><Eq><FieldRef Name='RefText'/><Value Type='Text'>" + Reference+ "</Value></Eq></Where> </Query></View>";

//alert(Reference);

var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml(queryString);

它总是给我列表的每个列表项,有谁知道正确的CAMLQuery将如何?

答案

如果在查询中只需要一个项目添加行限制:

<RowLimit>1</RowLimit>

如果您在查询中遇到问题,请检查RefText字段类型。是文字还是其他类型?

以上是关于仅使用CAML检索一个Listitem的主要内容,如果未能解决你的问题,请参考以下文章

在 Arraylist 的 listview 的 listitem 上显示值

如何从Microsoft.SharePoint.Client.ListItem检索所有属性?

Sharepoint Online 突出显示的内容 Web 部件 - 显示文件子文件夹 CAML 查询

ListItem 的 items 属性上的 XTemplate 定义

SharePoint CAML 查询在生成器中有效,但在代码中无效

使用CAML比较SharePoint“人员或组”字段