简体   繁体   English

Caml查询不适用于视图创建共享点

[英]Caml query not working for view creation sharepoint

I am creating a Sharepoint List View using C# CSOM code. 我正在使用C#CSOM代码创建一个Sharepoint列表视图。 I'm using ViewCreationInformation to create my view. 我正在使用ViewCreationInformation创建我的视图。 I'm facing problem in writing the query for it. 我在为其编写查询时遇到问题。

Writing this works: 编写此作品:

            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);

But If I change the query to this: 但是,如果我将查询更改为此:

            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>";

Then the View displays an error: TypeError: Unable to get property 'substring' of undefined or null reference 然后,视图显示错误: TypeError:无法获取未定义或空引用的属性“子字符串”

You can check the link or here is the error: TypeError: Unable to get property 'substring' of undefined or null reference 您可以检查链接,或者这里是错误:TypeError:无法获取未定义或空引用的属性“子字符串”

  TypeError: Unable to get property 'substring' of undefined or null referenceTypeError: Unable to get property '_events' of undefined or null reference 

Does anyone have any idea about this? 有人对此有任何想法吗? I've searched many places and I found similar codes everywhere. 我搜索了很多地方,到处都发现了类似的代码。 I don't know why this code is not working. 我不知道为什么这段代码不起作用。

Ok the problem was with GroupLimit=""30"". 好的,问题出在GroupLimit =“” 30“”。 Query without GroupLimit works totally fine. 没有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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM