[英]Caml query not working for view creation sharepoint
我正在使用C#CSOM代碼創建一個Sharepoint列表視圖。 我正在使用ViewCreationInformation創建我的視圖。 我在為其編寫查詢時遇到問題。
編寫此作品:
ViewCollection viewColl = list.Views;
string[] viewFields = {"Id", "Action", "Created", "Created By"};
ViewCreationInformation creationInfo = new ViewCreationInformation();
creationInfo.Title = "FromCode";
creationInfo.ViewFields = viewFields;
creationInfo.Query = @"<Where><Neq><FieldRef Name=""ConfidentialDocument""/><Value Type=""Choice"">No</Value></Neq></Where><GroupBy><FieldRef Name=""TemplateName"" /><FieldRef Name=""Title"" /></GroupBy><OrderBy><FieldRef Name=""Created"" Ascending=""True"" /></OrderBy>";
creationInfo.ViewTypeKind = ViewType.Html;
creationInfo.RowLimit = 30;
creationInfo.Paged = true;
creationInfo.SetAsDefaultView = true;
viewColl.Add(creationInfo);
但是,如果我將查詢更改為此:
creationInfo.Query = @"<Where><Neq><FieldRef Name=""ConfidentialDocument""/><Value Type=""Choice"">No</Value></Neq></Where><GroupBy Collapse=""TRUE"" GroupLimit=""30""><FieldRef Name=""TemplateName"" /><FieldRef Name=""Title"" /></GroupBy><OrderBy><FieldRef Name=""Created"" Ascending=""True"" /></OrderBy>";
然后,視圖顯示錯誤: TypeError:無法獲取未定義或空引用的屬性“子字符串”
您可以檢查鏈接,或者這里是錯誤:TypeError:無法獲取未定義或空引用的屬性“子字符串”
TypeError: Unable to get property 'substring' of undefined or null referenceTypeError: Unable to get property '_events' of undefined or null reference
有人對此有任何想法嗎? 我搜索了很多地方,到處都發現了類似的代碼。 我不知道為什么這段代碼不起作用。
好的,問題出在GroupLimit =“” 30“”。 沒有GroupLimit的查詢完全可以正常工作。
creationInfo.Query = @"<Where><Neq><FieldRef Name=""ConfidentialDocument""/><Value Type=""Choice"">No</Value></Neq></Where><GroupBy Collapse=""TRUE""><FieldRef Name=""TemplateName"" /><FieldRef Name=""Title"" /></GroupBy><OrderBy><FieldRef Name=""Created"" Ascending=""True"" /></OrderBy>";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.