Sharepoint 调查:从列表 Web 服务获取调查信息时如何识别问题字段?

发布于 2024-08-25 16:12:19 字数 881 浏览 2 评论 0原文

我想通过列表网络服务访问调查信息并显示调查中包含的问题。

结果包含大量Field节点,其中一些是调查中的问题。其他字段包含其他信息,例如作者、最后更改等。

我如何挑选问题?我原以为所有非问题都会被隐藏,但事实并非如此。

这是我目前的代码。它返回大约 16 个项目。该调查有 6 个问题...

// read question definitions
string[] HandleTypes = new string[] { "Number", "DateTime", "Text", "Choice", "GridChoice", "Boolean" };
var query = from n in node.Descendants(ns+"Field")
            where (n.Attribute("Hidden") == null || n.Attribute("Hidden").Value.ToLower() == "true")
            && (n.Attribute("Type") != null && HandleTypes.Contains(n.Attribute("Type").Value))
            select new Question(n.Attribute("ID").Value)
            {
                Text = n.Attribute("DisplayName").Value,
                QuestionType = n.Attribute("Type").Value,
                Element = n
            };

有人有什么想法吗?

I am wanting to access survey information via the Lists web service and display the questions contained in the survey.

The result contains a large number of Field nodes some of which are the questions in the survey. The other fields contain other information such as author, last changed etc.

How can I pick out the questions? I had thought that all non-questions would be hidden but this is not the case.

Here is my code as it is at the moment. It returns about 16 items. The survey has 6 questions...

// read question definitions
string[] HandleTypes = new string[] { "Number", "DateTime", "Text", "Choice", "GridChoice", "Boolean" };
var query = from n in node.Descendants(ns+"Field")
            where (n.Attribute("Hidden") == null || n.Attribute("Hidden").Value.ToLower() == "true")
            && (n.Attribute("Type") != null && HandleTypes.Contains(n.Attribute("Type").Value))
            select new Question(n.Attribute("ID").Value)
            {
                Text = n.Attribute("DisplayName").Value,
                QuestionType = n.Attribute("Type").Value,
                Element = n
            };

Ideas anyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

请止步禁区 2024-09-01 16:12:19

问题字段的属性“SourceID”是 GUID。
所有其他字段都有一个带有“http://schema...”的 SourceID

The attribute "SourceID" for question fields is a GUID.
All other fields have a SourceID with "http://schema..."

旧城烟雨 2024-09-01 16:12:19

我相信最简单的解决方法是找出内置字段的InternalName,将它们放入数组中,然后检查字段名是否在该数组中。例如,您很可能有“标题”、“创建者”、“作者”等。此页面将为您提供一些提示,其中哪些字段是内置的: http://www .johnholliday.net/downloads/fieldswss.htm

I believe the simplest workaround is to find out the InternalNames of the built-in fields, put them in an array, and then to check if the fieldname is in that array or not. For instance, you will most likely have "Title", "Created", "Author" et cetera. This page will give you some hints, which of the fields are built-in: http://www.johnholliday.net/downloads/fieldswss.htm

梦断已成空 2024-09-01 16:12:19

您可以使用 SPField.Group 来查找如果字段是“基本”列(例如 ID/作者等)或自定义列(将作为问题或页面分隔符),则输出。

页面分隔符是特定的字段类型所以你应该能够通过

if (SPField.Type == SPFieldTypes.PageSeperator)

You can use SPField.Group to find out if a field is a 'Base' column such as ID/Author etc or a custom column which will be a question or page separator.

The page separator is a particular field type so you should be able to get those by

if (SPField.Type == SPFieldTypes.PageSeperator)
つ低調成傷 2024-09-01 16:12:19

看起来它将所有新列(而不是来自父内容类型的列)视为问题。
仅检索问题的一种方法是获取“概述”视图中的所有字段(作者列除外);另一种方法是获取不是来自父内容类型的所有字段,即新字段。

It looks like it treats all new columns (not ones from the parent content types) as questions.
One way to retrieve only questions is to grab all the fields that are in "Overview" view (except for Author column); another way would be to grab all the fields that are not coming from a parent content type, i.e. new fields.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文