Question

Requirement : Webtemplate with custom document libraries along with custom content types to be used in sharepoint 2013 online

created the web template and content type, both are working fine in online sharepoint. But I am facing two major issues with list definition

1)Unable to include the custom content type as ContentTypeRef in the list definition schema. 2)Unable to figure out how to include the list definition to web template's onet.xml, I am trying to add the feature id to but upon creating a new site using the template the document library is missing.

Code:

Onet.xml

<?xml version="1.0" encoding="utf-8"?>
<Project Title="$Resources:onet_TeamWebSite;" Revision="3" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint" UIVersion="15" HideSiteContentsLink="true">
  <NavBars>
  </NavBars>
  <ListTemplates>
  </ListTemplates>
<Configurations>
    <Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/seattle.master">
      <Lists>
        <List FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Type="101" Title="$Resources:core,shareddocuments_Title_15;" Url="$Resources:core,shareddocuments_Folder;" OnQuickLaunch="TRUE" QuickLaunchHeading="TRUE" />
      </Lists>
      <SiteFeatures>
        <Feature ID="8b312a79-d117-44ef-81b2-453a71ccfea5" /> // Feature including the list definition
      </SiteFeatures>
      <WebFeatures>
      </WebFeatures>
    </Configuration>
  </Configurations>
  <ServerEmailFooter>$Resources:ServerEmailFooter;</ServerEmailFooter>
</Project>

Part of List definition's Schema.xml

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Resources" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Resources" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
  <MetaData>
    <ContentTypes>
      <ContentType ID="0x010100992CB78E42804317A18A5E40907EA235" Name="Custom Content Type" Group="Custom Content Type" Description="Custom Content Type" Inherits="TRUE" Version="0">
        <FieldRefs>
          <FieldRef ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Name="Organization/Author" Required="TRUE" />
          <FieldRef ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Name="Publication Date" Required="TRUE" />
          <FieldRef ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Name="Partners" Required="TRUE" />
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields>
      </Fields>
    <Views>

Within ContentTypes I have also tried using ContentTypeRef but that also not working

Content Type's Element.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Field ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Type="Text" Name="Organization/Author" DisplayName="Organization/Author" ShowInNewForm="FALSE" ShowInFileDlg="FALSE"></Field>
  <Field ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Type="DateTime" Name="Publication Date" DisplayName="Publication Date" Required="FALSE" EnforceUniqueValues="FALSE" ShowInNewForm="FALSE" ShowInFileDlg="FALSE"></Field>
  <Field ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Type="Choice" Name="Partners" DisplayName="Partners" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Dropdown" FillInChoice="FALSE">  
    <CHOICES>
      <CHOICE>Yes</CHOICE>
      <CHOICE>No</CHOICE>
    </CHOICES>
  </Field>

  <!-- Parent ContentType: Document (0x0101) -->
  <ContentType ID="0x010100992CB78E42804317A18A5E40907EA235" Name="Custom Content Type" Group="Custom Content Type" Description="Custom Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Name="Organization/Author" Required="TRUE" />
      <FieldRef ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Name="Publication Date" Required="TRUE" />
      <FieldRef ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Name="Partners" Required="TRUE" />
    </FieldRefs>
  </ContentType>
</Elements>

Can anyone suggest what am i doing wrong?

Few more thing, All three things (Webtemplate, content type, and list definition) are included in same feature which is scoped to site, as I will be deploying it to sharepoint online which is sandboxed architecture.

Was it helpful?

Solution

I'd like to suggest you restructure your code a bit if I may. Put the web template in its own solution. Get that working first.

Then create a second solution that includes the content type and list. Its feature should be scoped to Web, not Site. I don't see any issues with your schema, and VS2012 in any case has a list designer wizard, and if you used that you should be OK.

The reason I am suggesting 2 solutions is because web templates complicate the development workflow. Redeploying it entails deleting and recreating the whole site. There's no need to do that if you're only working on the list. With your list in a separate solution your redeployments will go much quicker.

If you need everything in one solution you can put them back togather once everything is working, but you need to have two features: Your web template must be in a Site-scoped feature, and your list needs to be in a Web-scoped feature. The fields and content type, I think, might be OK in either scope but I've always made them Web scoped.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top