问题:获取具有超过13个查找列的列表项 [英] Issue: Fetching list items which have more than 13 lookup columns
问题描述
使用CAML查询从超过13个查找列的SP列表中获取列表项会引发错误:"价值不在预期的
范围内"。我只需要从列表中检索一个查找列,这是要附加到列表的第14个查找列。
Using CAML query to fetch list items from a SP list with more than 13 lookup columns throws an error: "Value does not fall within the expected range". I require only 1 lookup column to be retrieved from the list, which is the 14th lookup column to be attached to the list.
我正在使用的查询:
The query I am using:
推荐答案
我在里面使用了CAML查询下面的CSOM得到一个非空的特定查找字段,在列表中我添加了14个查找字段,如你所说:
I used the CAML Query inside CSOM like below to get a specific lookup field which is not null, in the list I added 14 lookup fields as you said:
ClientContext clientContext = new ClientContext("http://sp/sites/jerry");
Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Jerrylist");
clientContext.Load(spList);
clientContext.ExecuteQuery();
if (spList != null && spList.ItemCount > 0)
{
Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml =
@"<View Scope='RecursiveAll'>
<Query>
<Where><IsNotNull><FieldRef Name='lookup14' /></IsNotNull></Where>
</Query>
<ViewFields><FieldRef Name='lookup14' /><FieldRef Name='ID' /></ViewFields>
</View>";
ListItemCollection listItems = spList.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (ListItem item in listItems)
{
FieldLookupValue lookupvalue = (FieldLookupValue)item["lookup14"];
Console.WriteLine(lookupvalue.LookupValue);
}
}
它将在foreach循环中按预期工作以获取查找值:
It will work as expected in foreach loop to get the lookup value:
< img alt =""src ="https://social.msdn.microsoft.com/Forums/getfile/1440301">
谢谢
最好的问候
这篇关于问题:获取具有超过13个查找列的列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!