我试图将数据从一个列表复制到另一个列表(这两个列表位于不同的站点)以及查找列。但是,我得到一个错误的查询字段为:值不在预期范围内 - SharePoint查找字段的例外
值不在预期范围内
代码的工作和数据被复制其他非查找字段。我尝试了所有可能的方式,包括增加列表视图查找阈值和所有可能的代码方式,但仍然错误仍然存在于ExecuteQuery()
。
下面是我对查找字段代码:
if (field is FieldLookup && field.InternalName == "Country")
{
var CountryLookup = (item.FieldValues["Country"] as FieldLookupValue).LookupValue.ToString();
var CountryLookupId = (item.FieldValues["Country"] as FieldLookupValue).LookupId.ToString();
FieldLookupValue flvRDS = new FieldLookupValue();
flvRDS.LookupId = int.Parse(CountryLookupId);
itemToCreate["Country"] = flvRDS;
itemToCreate.Update();
destContext.ExecuteQuery();
}
帮助真的赞赏。
实际上,item是我阅读的列表项中的现有数据,itemToCreate是我需要复制它的新项目。另外,我在CountryLookup&CountryLookupId中分别获取国家名称和ID。只是他们没有被复制。 – Pratik
尝试检索查找的项目的ID而不是LookupId,就像我在代码中那样。 – Kilazur