0

In VisualStudio 2012 I have a custom content type that I want to use in a ListInstance. When I create a ListDefinition or ListInstance using VisualStudio and add my ContentType I get feature activation errors. Yet if I create a generic ListInstance it functions correctly and if I add my ContentType through the web interface to the ANY list it works fine too.

What do I need to do to get the ListDefinition and ListInstance to function correctly.

The content type is based on an Item and has several custom SiteColumns.

  • My SiteColumns are in Feature1
  • My ContentTypes are in Feature2
  • My ListDefinition and ListInstances are in Feature3
  • Features are scoped to web.
  • Features are set up with the correct dependencies.
  • Features are shown in the correct order in the package.

Content Type

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Item (0x01) -->
  <ContentType ID="0x0100BE5BB437E28E4931960FD3AB89883799" Name="My Concept" Group="My Content Types" Description="My Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{600c95a5-c81c-4c2d-a1b7-1b90c1fa6537}" DisplayName="Concept ID" Required="FALSE" Name="ConceptID"  ShowInEditForm="False" ShowInNewForm="False" />
      <FieldRef ID="{0b8e6761-062c-446b-9bf2-28b0c238684d}" DisplayName="Concept Description" Required="True" Name="Project Description" />
      <FieldRef ID="{99719dc5-4a0a-4b04-b2f8-353630a0d271}" DisplayName="Proposed Project Manager" Required="TRUE" Name="Project Manager" />
      <FieldRef ID="{a24d0da2-8329-4da3-9245-251d167626b6}" DisplayName="Proposed Project Sponsor" Required="TRUE" Name="Project Sponsor" />
      <FieldRef ID="{49e5c95d-24bb-4575-9450-d6489cc825f7}" DisplayName="Expected Output" Required="True" Name="Expected Output" />
      <FieldRef ID="{2a3d45c7-b841-4d09-b504-ea896d9e4460}" DisplayName="Development Budget" Required="TRUE" Description="Enter 0 if no development budget is required" Name="Development Budget" />
      <FieldRef ID="{98d0a6df-edfa-4391-a1af-fd4fc2c996cb}" DisplayName="Budget" Required="TRUE" Name="Budget" />
      <FieldRef ID="{5aa99327-7751-4efb-b018-bc579e3a84ae}" DisplayName="Proposed Start Date" Required="TRUE" Name="Start Date" Format="DateOnly" />
      <FieldRef ID="{8f6305fb-b742-4c92-9d86-2c1d1d30d814}" DisplayName="Proposed End Date" Required="TRUE" Name="End Date" Format="DateOnly" />
      <FieldRef ID="{203929d8-049a-429c-adb8-282213061e39}" DisplayName="Consideration of Strategic Alignment" Required="True" Name="Consideration of Strategic Alignment" />
      <FieldRef ID="{493918ed-312d-4f86-a9ee-1e385318c67b}" DisplayName="Consideration of Conservation Principles" Required="True" Name="Consideration of Conservation Principles" />
      <FieldRef ID="{9dbf8242-57ef-4b92-b743-c4f747f10300}" DisplayName="Business Case Uploaded" Required="FALSE" Name="Business Case Uploaded" />
      <FieldRef ID="{207507fb-ce58-49eb-9cea-396a70015930}" DisplayName="Supporting DocumeMy Uploaded" Required="FALSE" Name="Project Paper Uploaded" />
      <FieldRef ID="{9b44e710-1396-432c-8b1c-8a212468df9b}" DisplayName="Submit For Approval" Required="FALSE" Name="Submit For Approval" ShowInEditForm="True" ShowInNewForm="False" />
      <FieldRef ID="{a6ac48b4-39fa-4c23-90c6-03600e91f4b7}" DisplayName="Development Site Created" Required="FALSE" Name="DevelopmeMyiteCreated" ShowInEditForm="False" ShowInNewForm="False" />
      <FieldRef ID="{287c17a9-c869-46fe-a645-15ffcb7075cd}" DisplayName="Project Site Created" Required="FALSE" Name="ProjectSiteCreated" ShowInEditForm="False" ShowInNewForm="False" />
    </FieldRefs>
  </ContentType>
</ElemeMy>

List Definition

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="My Concept" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/My Concept" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
  <MetaData>
    <ContentTypes>


      <ContentType ID="0x0100BE5BB437E28E4931960FD3AB89883799" Name="My Concept" Group="My Content Types" Description="My Content Type" Inherits="TRUE" Version="0">
        <FieldRefs>
          <FieldRef ID="{600c95a5-c81c-4c2d-a1b7-1b90c1fa6537}" DisplayName="Concept ID" Required="FALSE" Name="ConceptID" ShowInEditForm="False" ShowInNewForm="False" />
          <FieldRef ID="{0b8e6761-062c-446b-9bf2-28b0c238684d}" DisplayName="Concept Description" Required="True" Name="Project Description" />
          <FieldRef ID="{99719dc5-4a0a-4b04-b2f8-353630a0d271}" DisplayName="Proposed Project Manager" Required="TRUE" Name="Project Manager" />
          <FieldRef ID="{a24d0da2-8329-4da3-9245-251d167626b6}" DisplayName="Proposed Project Sponsor" Required="TRUE" Name="Project Sponsor" />
          <FieldRef ID="{49e5c95d-24bb-4575-9450-d6489cc825f7}" DisplayName="Expected Output" Required="True" Name="Expected Output" />
          <FieldRef ID="{2a3d45c7-b841-4d09-b504-ea896d9e4460}" DisplayName="Development Budget" Required="TRUE" Description="Enter 0 if no development budget is required" Name="Development Budget" />
          <FieldRef ID="{98d0a6df-edfa-4391-a1af-fd4fc2c996cb}" DisplayName="Budget" Required="TRUE" Name="Budget" />
          <FieldRef ID="{5aa99327-7751-4efb-b018-bc579e3a84ae}" DisplayName="Proposed Start Date" Required="TRUE" Name="Start Date" Format="DateOnly" />
          <FieldRef ID="{8f6305fb-b742-4c92-9d86-2c1d1d30d814}" DisplayName="Proposed End Date" Required="TRUE" Name="End Date" Format="DateOnly" />
          <FieldRef ID="{203929d8-049a-429c-adb8-282213061e39}" DisplayName="Consideration of Strategic Alignment" Required="True" Name="Consideration of Strategic Alignment" />
          <FieldRef ID="{493918ed-312d-4f86-a9ee-1e385318c67b}" DisplayName="Consideration of Conservation Principles" Required="True" Name="Consideration of Conservation Principles" />
          <FieldRef ID="{9dbf8242-57ef-4b92-b743-c4f747f10300}" DisplayName="Business Case Uploaded" Required="FALSE" Name="Business Case Uploaded" />
          <FieldRef ID="{207507fb-ce58-49eb-9cea-396a70015930}" DisplayName="Supporting DocumeMy Uploaded" Required="FALSE" Name="Project Paper Uploaded" />
          <FieldRef ID="{9b44e710-1396-432c-8b1c-8a212468df9b}" DisplayName="Submit For Approval" Required="FALSE" Name="Submit For Approval" ShowInEditForm="True" ShowInNewForm="False" />
          <FieldRef ID="{a6ac48b4-39fa-4c23-90c6-03600e91f4b7}" DisplayName="Development Site Created" Required="FALSE" Name="DevelopmeMyiteCreated" ShowInEditForm="False" ShowInNewForm="False" />
          <FieldRef ID="{287c17a9-c869-46fe-a645-15ffcb7075cd}" DisplayName="Project Site Created" Required="FALSE" Name="ProjectSiteCreated" ShowInEditForm="False" ShowInNewForm="False" />
        </FieldRefs>
      </ContentType>
      <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>
    <Fields>

      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="$Resources:core,Title;" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" MaxLength="255" />
      <Field ID="{600c95a5-c81c-4c2d-a1b7-1b90c1fa6537}" Name="ConceptID" DisplayName="Concept ID" Type="Text" Required="FALSE" Group="My Projects Columns" ShowInEditForm="False" ShowInNewForm="False"></Field>
      <Field ID="{0b8e6761-062c-446b-9bf2-28b0c238684d}" Name="Project Description" DisplayName="Concept Description" Type="Note" Required="True" Group="My Projects Columns"></Field>
      <Field ID="{99719dc5-4a0a-4b04-b2f8-353630a0d271}" Name="Project Manager" DisplayName="Proposed Project Manager" Type="User" Required="TRUE" Group="My Projects Columns"></Field>
      <Field ID="{a24d0da2-8329-4da3-9245-251d167626b6}" Name="Project Sponsor" DisplayName="Proposed Project Sponsor" Type="User" Required="TRUE" Group="My Projects Columns"></Field>
      <Field ID="{49e5c95d-24bb-4575-9450-d6489cc825f7}" Name="Expected Output" DisplayName="Expected Output" Type="Note" Required="True" Group="My Projects Columns"></Field>
      <Field ID="{2a3d45c7-b841-4d09-b504-ea896d9e4460}" Name="Development Budget" DisplayName="Development Budget" Type="Currency" Required="TRUE" Description="Enter 0 if no development budget is required" Group="My Projects Columns"></Field>
      <Field ID="{98d0a6df-edfa-4391-a1af-fd4fc2c996cb}" Name="Budget" DisplayName="Budget" Type="Currency" Required="TRUE" Group="My Projects Columns"></Field>
      <Field ID="{5aa99327-7751-4efb-b018-bc579e3a84ae}" Name="Start Date" DisplayName="Proposed Start Date" Type="DateTime" Required="TRUE" Format="DateOnly" Group="My Projects Columns"></Field>
      <Field ID="{8f6305fb-b742-4c92-9d86-2c1d1d30d814}" Name="End Date" DisplayName="Proposed End Date" Type="DateTime" Required="TRUE" Format="DateOnly" Group="My Projects Columns"></Field>
      <Field ID="{203929d8-049a-429c-adb8-282213061e39}" Name="Consideration of Strategic Alignment" DisplayName="Consideration of Strategic Alignment" Type="Note" Required="True" Group="My Projects Columns"></Field>
      <Field ID="{493918ed-312d-4f86-a9ee-1e385318c67b}" Name="Consideration of Conservation Principles" DisplayName="Consideration of Conservation Principles" Type="Note" Required="True" Group="My Projects Columns"></Field>
      <Field ID="{9dbf8242-57ef-4b92-b743-c4f747f10300}" Name="Business Case Uploaded" DisplayName="Business Case Uploaded" Type="Boolean" Required="FALSE" Group="My Projects Columns"></Field>
      <Field ID="{207507fb-ce58-49eb-9cea-396a70015930}" Name="Project Paper Uploaded" DisplayName="Supporting DocumeMy Uploaded" Type="Boolean" Required="FALSE" Group="My Projects Columns"></Field>
      <Field ID="{9b44e710-1396-432c-8b1c-8a212468df9b}" Name="Submit For Approval" DisplayName="Submit For Approval" Type="Boolean" Required="FALSE" Group="My Projects Columns" ShowInEditForm="True" ShowInNewForm="False"></Field>
      <Field ID="{a6ac48b4-39fa-4c23-90c6-03600e91f4b7}" Name="DevelopmeMyiteCreated" DisplayName="Development Site Created" Type="Boolean" Required="FALSE" Group="My Projects Columns" ShowInEditForm="False" ShowInNewForm="False"></Field>
      <Field ID="{287c17a9-c869-46fe-a645-15ffcb7075cd}" Name="ProjectSiteCreated" DisplayName="Project Site Created" Type="Boolean" Required="FALSE" Group="My Projects Columns" ShowInEditForm="False" ShowInNewForm="False"></Field>
    </Fields>
    <Views>


      <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>

          <FieldRef Name="LinkTitleNoMenu"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>

            <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
          <ParameterBinding Name="NoAnnouncemeMy" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncemeMyHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
        </ParameterBindings>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/generic.png?rev=23" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <JSLink>clienttemplates.js</JSLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>

          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef Name="ConceptID" />
          <FieldRef Name="Project Description" />
          <FieldRef Name="Project Manager" />
          <FieldRef Name="Project Sponsor" />
          <FieldRef Name="Expected Output" />
          <FieldRef Name="Development Budget" />
          <FieldRef Name="Budget" />
          <FieldRef Name="Start Date" />
          <FieldRef Name="End Date" />
          <FieldRef Name="Consideration of Strategic Alignment" />
          <FieldRef Name="Consideration of Conservation Principles" />
          <FieldRef Name="Business Case Uploaded" />
          <FieldRef Name="Project Paper Uploaded" />
          <FieldRef Name="Submit For Approval" />
          <FieldRef Name="DevelopmeMyiteCreated" />
          <FieldRef Name="ProjectSiteCreated" />
        </ViewFields>
        <Query>
          <OrderBy>

            <FieldRef Name="ID"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncemeMy" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncemeMyHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>

Error

[COMException (0x80004005): Cannot complete this action.

Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>]
   Microsoft.SharePoint.Library.SPRequestInternalClass.CreateListFromFormPost(String bstrUrl, String& pbstrGuid, String& pbstrNextUrl) +0
   Microsoft.SharePoint.Library.SPRequest.CreateListFromFormPost(String bstrUrl, String& pbstrGuid, String& pbstrNextUrl) +204

[SPException: Cannot complete this action.

Please try again.]
   Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +146
   Microsoft.SharePoint.Library.SPRequest.CreateListFromFormPost(String bstrUrl, String& pbstrGuid, String& pbstrNextUrl) +462
   Microsoft.SharePoint.SPListCollection.CreateListFromRpc(NameValueCollection queryString, Uri& nextUrl) +1796
   Microsoft.SharePoint.ApplicationPages.NewListPage.BtnOk_Click(Object sender, EventArgs args) +481
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +146
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3586
  • Have you tried putting site columns, content types and the list definition in Site scoped features and put the list instance in a Web scoped feature? After deploying active the site features and then the web features? – Naim Murati Jan 30 '14 at 14:18
  • Also try by putting list definition and list instance in separate features? – Naim Murati Jan 30 '14 at 14:26
1

Try:

  1. Step by step exclude some block definitions from list definition to find out what exactly doesn't work.
  2. Another recomendation, do not use gaps in Name property of the Field definition, it will be changed into something like _x2000, could be error with FieldRef of content type connection.
  3. In FieldRef try to use only necessary properties like ID, Name or ShowId*... properties like DisplayName will be copied anyway..
  4. If you tried to create your list through the interface and it worked, try to open created list definition through Sharepoint Manager and identify differences.
  • I think it was to do with spaces in names - essentially I removed my ListDefinition and ListInstance, renamed my SiteColumns and ContentType Fields with no spaces and recreated my ListDefinition and ListInstance, it all deploys nicely now. – Mauro Jan 30 '14 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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