[英]What is wrong with this caml query to get exception "can not complete this action. Please try again"?
[英]executing a caml query to get a lookup field : "Cannot complete this action.Please try again."?
這是我的 caml 查詢代碼,用於獲取本地 SharePoint 2016 (CSOM) 中查找字段的值。
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='myLookupField' LookupId='TRUE'/>
<Value Type='Lookup'>18456</Value>
</Eq>
</Where>
</Query>
</View>
嘗試刪除這部分“LookupId='TRUE'”,但仍然收到此異常:“無法完成此操作。請重試。” 我在 U2U caml 查詢構建器中運行這個 caml 查詢,但它有效。
在 CSOM 中測試了 CAML,如下所示,它正在工作:
using (ClientContext ctx=new ClientContext("http://sp/sites/dev/"))
{
List list = ctx.Web.Lists.GetByTitle("MyList22");
CamlQuery caml = new CamlQuery();
caml.ViewXml = "<View><Query><Where><Eq><FieldRef Name='myLookupField' LookupId='TRUE'/><Value Type='Lookup'>1</Value></Eq></Where></Query></View>";
ListItemCollection items = list.GetItems(caml);
ctx.Load(items);
ctx.ExecuteQuery();
foreach (ListItem item in items)
{
FieldLookupValue value = item["myLookupField"] as FieldLookupValue;
Console.WriteLine("LookupId: "+ value.LookupId);
Console.WriteLine("LookupValue: "+ value.LookupValue);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.