2

So far I manage with the below sample to deploy a list instance of survey from VS2012, how ever I cannot seem to add the question in the Im getting always when deploying "Error occurred in deployment step 'Activate Feature' Column 'Q1' does not exists. It may have been deleted by another user... here are my XML files

so basically my question how exactly can I add question field to the list Instance and schema.xml

TIA

so far I have been create list instance as follow:

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">
    <Data>
      <Rows>
        <Row>
          <Field Name='Q1'>Enter Choice #1</Field>
        </Row>
      </Rows>
   </Data>
  </ListInstance>
 </Elements>

List elements.xml :

  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListTemplate
        Name="List1"
        Type="102"
        BaseType="4"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="410"
        DisplayName="List1"
        Description="My List Definition"
        Image="/_layouts/images/itgen.png"/>
    </Elements>

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/">
 <MetaData>
   <Fields>
    <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">
     <CHOICES>
        <CHOICE>Enter Choice #1</CHOICE>
        <CHOICE>Enter Choice #2</CHOICE>
        <CHOICE>Enter Choice #3</CHOICE>
      </CHOICES>
   </Field>
  </Fields>
  </MetaData>

2 Answers 2

1

I used following steps to create custom survey list:

  1. Create ListInstance. Elements.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <ListInstance Title="CustomSurvey3"
                    OnQuickLaunch="TRUE"
                    TemplateType="102"
                    Url="Lists/CustomSurvey3"
                    FeatureId="{00BFEA71-EB8A-40B1-80C7-506BE7590102}"
                    Description="My List Instance"
                    CustomSchema="CustomSurvey3/Schema.xml">
        <Data>
          <Rows>
            <Row>
              <Field Name='Q1'>Enter Choice #1</Field>
            </Row>
          </Rows>
        </Data>
      </ListInstance>
    </Elements>
    
  2. Create custom schema. Add xml file "Schema.xml" to list instance's folder and set property Deployment type to "ElementFile" (notice that ListInstance points to custom schema via attribute "CustomSchema"). Schema.xml:

     <?xml version="1.0" encoding="utf-8" ?>
    <List xmlns:ows="Microsoft SharePoint" Title="Basic List" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Basic List" BaseType="4" xmlns="http://schemas.microsoft.com/sharepoint/">
      <MetaData>
    <ContentTypes>
    </ContentTypes>
    <Fields>
      <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">
        <CHOICES>
          <CHOICE>Enter Choice #1</CHOICE>
          <CHOICE>Enter Choice #2</CHOICE>
          <CHOICE>Enter Choice #3</CHOICE>
        </CHOICES>
      </Field>
    </Fields>
    <Views>
      <View BaseViewID="0" FreeForm="TRUE" ReadOnly="TRUE" TabularView="FALSE" Type="HTML" CssStyleSheet="survey.css">
        <Toolbar Position="After" Type="Freeform">
          <IfHasRights>
            <RightsChoices>
              <RightsGroup PermAddListItems="required" />
            </RightsChoices>
            <Then>
              <Switch>
                <Expr>
                  <GetVar Name="MasterVersion" />
                </Expr>
                <Case Value="4">
                  <HTML><![CDATA[<div class="tb"><img src="/_layouts/images/caladd.gif" alt="" />&#160;<a class="ms-addnew" id="idNewSurveyResponse" href="]]></HTML>
                  <URL Cmd="New" />
                  <HTML><![CDATA[" onclick="javascript:NewItem(']]></HTML>
                  <ScriptQuote NotAddingQuote="TRUE">
                    <URL Cmd="New" />
                  </ScriptQuote>
                  <HTML><![CDATA[', true);javascript:return false;" target="_self">]]></HTML>
                  <HTML>$Resources:core,RespondToSurvey;</HTML>
                  <HTML><![CDATA[</a></div>]]></HTML>
                </Case>
                <Default>
                  <HTML><![CDATA[ <table width="100%" cellpadding="0" cellspacing="0" border="0" > <tr> <td colspan="2" class="ms-partline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td> </tr> <tr> <td class="ms-addnew" style="padding-bottom: 3px"> <img src="/_layouts/images/rect.gif" alt="" />&#160;<a class="ms-addnew" id="idNewSurveyResponse" href="]]></HTML>
                  <URL Cmd="New" />
                  <HTML><![CDATA[" onclick="javascript:NewItem(']]></HTML>
                  <ScriptQuote NotAddingQuote="TRUE">
                    <URL Cmd="New" />
                  </ScriptQuote>
                  <HTML><![CDATA[', true);javascript:return false;" target="_self">]]></HTML>
                  <HTML>$Resources:core,RespondToSurvey;</HTML>
                  <HTML><![CDATA[</a> </td> </tr> <tr><td><img src="/_layouts/images/blank.gif" width='1' height='5' alt="" /></td></tr> </table>]]></HTML>
                </Default>
              </Switch>
            </Then>
          </IfHasRights>
        </Toolbar>
        <ViewFields>
        </ViewFields>
        <ViewEmpty>
          <HTML>
            <![CDATA[
                            <table class="ms-summarystandardbody" cellpadding="0" cellspacing="0" width="600px" style="margin: 10px;" border="0" rules="rows"> <tr> <td class="ms-formlabel" width="190px" id="overview01">]]><![CDATA[$Resources:core,survey_name;]]><![CDATA[</td> <td class="ms-formbody" >]]>
          </HTML>
          <ListProperty Select="Title" HTMLEncode="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" valign="top" id="overview02">]]><![CDATA[$Resources:core,survey_desc;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="Description" AutoHyperLink="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" id="overview03">]]><![CDATA[$Resources:core,time_created;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="Created" HTMLEncode="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" id="overview04">]]><![CDATA[$Resources:core,number_of_response;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="ItemCount" ForInstance="TRUE" />
          <HTML>
            <![CDATA[</td> </tr> <tr> <td><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td> </tr> </table>
                        ]]>
          </HTML>
        </ViewEmpty>
        <XslLink>main.xsl</XslLink>
      </View>
      <View BaseViewID="3" Type="HTML" WebPartZoneID="Main" TabularView="FALSE" DefaultView="TRUE" DisplayName="$Resources:core,Overview;" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/survey.png" Url="overview.aspx" FreeForm="TRUE" ReadOnly="TRUE" CssStyleSheet="survey.css">
        <Toolbar Type="Standard" />
        <ViewFields>
          <FieldRef Name="Author" />
        </ViewFields>
        <ViewEmpty>
          <HTML>
            <![CDATA[
                        <table class="ms-summarystandardbody" cellpadding="0" cellspacing="0" width="600px" style="margin: 10px;" border="0" rules="rows"> <tr> <td class="ms-formlabel" width="190px" id="overview01">]]><![CDATA[$Resources:core,survey_name;]]><![CDATA[</td> <td class="ms-formbody" >]]>
          </HTML>
          <ListProperty Select="Title" HTMLEncode="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" valign="top" id="overview02">]]><![CDATA[$Resources:core,survey_desc;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="Description" AutoHyperLink="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" id="overview03">]]><![CDATA[$Resources:core,time_created;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="Created" HTMLEncode="TRUE" />
          <HTML><![CDATA[</td> </tr> <tr> <td class="ms-formlabel" id="overview04">]]><![CDATA[$Resources:core,number_of_response;]]><![CDATA[</td> <td class="ms-formbody">]]></HTML>
          <ListProperty Select="ItemCount" ForInstance="TRUE" />
          <HTML>
            <![CDATA[</td> </tr> <tr> <td><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td> </tr> </table>
                        <table border="0" style="margin: 0px 8px 0px 8px;">
                            <tr><td><img src="/_layouts/images/blank.gif" width="1" height="4" alt="" /></td></tr>
                            <tr>
                                <td nowrap="nowrap">
                                <img src="/_layouts/images/rect.gif" alt="" /><span class="ms-toolbar">&#160;</span>
                                <a class="ms-toolbar" accesskey="R" id="diidSurveyResults" href="]]>
          </HTML>
          <ListUrlDir HTMLEncode="TRUE" />
          <HTML>
            <![CDATA[/summary.aspx">$Resources:core,Graphical_Summary_Responses;</a>
                                <span class="ms-toolbar">&#160;</span>
                                </td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap">
                                <img src="/_layouts/images/rect.gif" alt="" /><span class="ms-toolbar">&#160;</span>
                                <a class="ms-toolbar" accesskey="U" id="diidResultsByUser" href="]]>
          </HTML>
          <ListUrlDir HTMLEncode="TRUE" />
          <HTML>
            <![CDATA[/AllItems.aspx">$Resources:core,Show_All_Responses;</a>
                                <span class="ms-toolbar">&#160;</span>
                                </td>
                            </tr>
                        </table>  
                        ]]>
          </HTML>
        </ViewEmpty>
        <XslLink>main.xsl</XslLink>
      </View>
      <View BaseViewID="1" Type="Chart" WebPartZoneID="Main" DisplayName="$Resources:core,Graphical_Summary;" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/survey.png" Url="summary.aspx" FreeForm="TRUE" ReadOnly="TRUE" CssStyleSheet="survey.css">
        <Toolbar Type="Standard" />
        <ViewFields>
        </ViewFields>
      </View>
      <View BaseViewID="2" Type="HTML" WebPartZoneID="Main" TabularView="FALSE" DisplayName="$Resources:core,All_Responses;" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/survey.png" Url="AllItems.aspx">
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Toolbar Type="Standard" />
        <ViewFields>
          <FieldRef Name="DisplayResponse">
          </FieldRef>
          <FieldRef Name="Author">
          </FieldRef>
          <FieldRef Name="Modified">
          </FieldRef>
          <FieldRef Name="Completed">
          </FieldRef>
        </ViewFields>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noresponses)" />
        </ParameterBindings>
        <Query>
          <OrderBy>
            <FieldRef Name="ID">
            </FieldRef>
          </OrderBy>
        </Query>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" Template="ListForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" Template="SurveyForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" Template="SurveyForm" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>
    

  3. Resulting structure: Image

1
  • Did it help you?
    – Andrew
    Commented May 1, 2013 at 7:47
0

Try to change TemplateType in ListInstance to your own. "102" is standard Survey template without your field Q1. I think that's why Sharepoint throws error when data populates from "Data" section.

As result, change:

  • In ListTemplate: Type from 102 to your own (for ex 10001)
  • In ListInstance: TemplateType from 102 to your own.
1
  • when I change TemplateType in ListInstance to my own there is an error : Cannot complete this action I Guess : probably can't be changed like that when the attribute feature set to : 00BFEA71-EB8A-40B1-80C7-506BE7590102 what next to try ?
    – Ronen
    Commented Apr 17, 2013 at 5:51

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.