Is it possible to include a survey and it's questions in the onet.xml ? I know you can create the survey list, but is it possible to include the questions as well ?


so far I have been create list instance as follows ListInstance : elements.xml

  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <ListInstance Title="List1" OnQuickLaunch="TRUE" TemplateType="102" 
            FeatureId="00BFEA71-EB8A-40B1-80C7-506BE7590102" Url="Lists/List1" 
            Description="My List Instance">
      <Field Name='Q1'>Enter Choice #1</Field>

List elements.xml :

   <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    Description="My List Definition"

and Schema.xml

     <List xmlns:ows="Microsoft SharePoint" Title="List1" FolderCreation="FALSE"   Direction="$Resources:Direction;" Url="Lists/List1" BaseType="4" xmlns="http://schemas.microsoft.com/sharepoint/">
        <Field Type="Choice" DisplayName="Q1" Required="TRUE"   EnforceUniqueValues="TRUE" Indexed="TRUE" Format="RadioButtons" FillInChoice="FALSE" ID="{354d7076-eb3c-4413-837f-764f9ba86d79}" SourceID="{14afce0c-774c-474e-8b75-db12f85d4605}" StaticName="Q1" Name="Q1" ColName="nvarchar3" RowOrdinal="0">
            <CHOICE>Enter Choice #1</CHOICE>
            <CHOICE>Enter Choice #2</CHOICE>
            <CHOICE>Enter Choice #3</CHOICE>

When I activate my feature I get error:

System.ArgumentException : column Q1 not exists or has been deleted

Hope for any help..

1 Answer 1


Generally you could provision List instances and data using something similar to below:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListInstance Title="My Survey"
      <Field Name='Title'>My title field value</Field>

However, as Survey is more "special", if you want the actual Questions are Columns to your list - and most undocumented (in terms of field types - list on MSDN avaiable at http://msdn.microsoft.com/en-us/library/ms948164.aspx)

So you would need to actual define the questions in the columns, whereas the actual Responses are in the "data" element. As questions are defined as custom fields with particular name, so must contains question field, and this field must match with field definition schema - lots of work! One alternative could be to export the list as STP and have a look inside at the manifest.

Try something as follows (haven't been able to find the equivalent for a Likert scale by example - but simple questions should be as regular columns). Also for separator columns i've discovered that a field of type "PageSeparator" basically inserts a page break in your survey:

<Field Type="Choice" DisplayName="Question 1" Required="FALSE" Format="RadioButtons" FillInChoice="FALSE" ID="YOUR_GUID_MUST_GO_HERE" StaticName="Question_x0020_1" Name="Question_x0020_1" ColName="nvarchar3" RowOrdinal="0"><CHOICES><CHOICE>Enter Choice #1</CHOICE><CHOICE>Enter Choice #2</CHOICE><CHOICE>Enter Choice #3</CHOICE></CHOICES></Field>
  • Thank you very much for your help and direction , I'll start checking it out.
    – Ronen
    Apr 10, 2013 at 5:27
  • I starting to work on this, I have a question though, How I "tells" the ListInstance that the field's I will create will belong to it ?
    – Ronen
    Apr 10, 2013 at 12:05
  • You need a list definition which containes FieldRefs. Usually Field tags are defined either on the same XML file or another, look here sharepointfever.blogspot.ch/2012/04/… (VS 2010). If you've never did it previously, rather create your own via the Web-ui, save as template and import to have a look at it. Apr 10, 2013 at 12:58
  • thank you for that, my problems seems not over :) as I want to create list definition for survey, I can't seems to find one in VS2012.... is there even though a way of doing it ?
    – Ronen
    Apr 10, 2013 at 13:05
  • there is none for Survey, or otherwise! you would use a generic and than choose base list template, etc. Apr 10, 2013 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.