开发者

Sharepoint survey: How to identify the question fields when fetching survey information from the Lists web service?

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 fie开发者_运维问答lds 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?


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


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


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜