3

I have a created a SharePoint 2013 document library programmatically within a custom site definition. The problem is that when I browse to the AllItems.aspx of that Doc Library a "new item" button appears instead of "new document" like in OOB document library.

Besides, when I click on "New item" button no action is fired. I'm only able to upload documments throughtout the ribbon or drag and drop function using chrome or firefox.

this is the Elements.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
<ListTemplate
    Name="ListDefinitionCommunityDocuments"
    Type="10000"
    BaseType="1"
    OnQuickLaunch="TRUE"
    SecurityBits="11"
    Sequence="110"
    DisplayName="$Resources:Intranet,ListDefinition_CommunityDocuments_DisplayName;"
    Description="$Resources:Intranet,ListDefinition_CommunityDocuments_Description;"
    Image="/_layouts/15/images/itdl.png"
    DocumentTemplate="121"/>
</Elements>

And this is the schema.xml

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="ListDefinitionCommunityDocuments" Direction="$Resources:Direction;" Url="ListDefinitionCommunityDocuments" BaseType="1" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>

      <ContentTypeRef ID="0x010100EC124370D330457F8AE8E5EC56DD1FE3" />
    </ContentTypes>
    <Fields>
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Toolbar Position="After" Type="Freeform">
          <IfHasRights>
            <RightsChoices>
              <RightsGroup PermAddListItems="required" />
            </RightsChoices>
            <Then>
              <HTML><![CDATA[<div class="tb"><img src="/_layouts/15/images/caladd.gif" alt="" />&#160;<a class="ms-addnew" id="idAddNewDoc" href="]]></HTML>
              <HttpVDir />
              <HTML><![CDATA[/_layouts/15/Upload.aspx?List=]]></HTML>
              <ListProperty Select="Name" />
              <HTML><![CDATA[&RootFolder=]]></HTML>
              <GetVar Name="RootFolder" URLEncode="TRUE" />
              <HTML><![CDATA[" onclick="javascript:NewItem(']]></HTML>
              <ScriptQuote NotAddingQuote="TRUE">
                <HttpVDir />
              </ScriptQuote>
              <HTML><![CDATA[/_layouts/15/Upload.aspx?List=]]></HTML>
              <ListProperty Select="Name" />
              <HTML><![CDATA[&RootFolder=]]></HTML>
              <GetVar Name="RootFolder" URLEncode="TRUE" />
              <HTML><![CDATA[', true);javascript:return false;" target="_self">]]></HTML>
              <HTML>$Resources:core,Add_New_Document;</HTML>
              <HTML><![CDATA[</a></div>]]></HTML>
            </Then>
          </IfHasRights>
        </Toolbar>
        <ViewFields>
          <FieldRef Name="DocIcon"></FieldRef>
          <FieldRef Name="LinkFilenameNoMenu"></FieldRef>
          <FieldRef Name="Editor"></FieldRef>
        </ViewFields>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noitemsinview_doclibrary)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noitemsinview_doclibrary_howto)" />
          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,Add_New_Document)" />
          <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,MoreDocuments)" />
        </ParameterBindings>
        <Query>
          <OrderBy>
            <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
          </OrderBy>
        </Query>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,All_Documents;" DefaultView="TRUE" MobileView="True" MobileDefaultView="True" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/dlicon.png" Url="Forms/AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <JSLink>clienttemplates.js</JSLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="DocIcon"></FieldRef>
          <FieldRef Name="LinkFilename"></FieldRef>
          <FieldRef Name="Modified"></FieldRef>
          <FieldRef Name="Editor"></FieldRef>
          <FieldRef Name="AverageRating" />
        </ViewFields>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noitemsinview_doclibrary)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noitemsinview_doclibrary_howto2)" />
        </ParameterBindings>
        <Query>
          <OrderBy>
            <FieldRef Name="FileLeafRef" />
          </OrderBy>
        </Query>
      </View>
      </Views>
    <Forms>
      <Form Type="DisplayForm" SetupPath="pages\form.aspx" Url="Forms/DispForm.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" SetupPath="pages\form.aspx" Url="Forms/EditForm.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="Forms/Upload.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>

Any idea? Thank you very much

7
  • Can you come up with a simpler schema for the purposes of the question. Your schema.xml is excessively long (according to the SE robot ;-). If you can create a simpler case that still has the problem there is a better chance someone will spot the problem.
    – SPDoctor
    Commented Jun 10, 2013 at 14:51
  • Sorry for the inconvenience. I just have edited the code Commented Jun 10, 2013 at 17:01
  • 1
    Hi dis you try to insert enablecontenttypes="True" in the schema.xml ?
    – Sascha
    Commented Jun 10, 2013 at 18:07
  • I will try the enableContentTypes="true" and I will tell you. Thank you very much Commented Jun 11, 2013 at 10:33
  • Hi @Sascha. It seem that works because now is opnening the dialog but I still have the same problem. The literal text is "new item" instead of "new document" ¿any idea? Commented Jun 12, 2013 at 9:18

3 Answers 3

3

I solved this issue changing the Elements.xml of the list instance and list definition. If you replace TemplateType="10000" and Type="10000" in both Elements.xml by TemplateType="101" and Type="101" everything works as expected.

Thank you all for your replies

0

I wonder if your content type 0x010100EC124370D330457F8AE8E5EC56DD1FE3 exists at the time your list definitions is pushed to the site collection. Are you deploying the CT in the same feature? I've experienced this before and ended up splitting the feature into 2 separate ones. Try changing your schema to reference 0x0101 instead and see how it goes. Alternatively, you could check on you document library settings which content types are associated with it.

2
  • This is what I have in elements.xml in Content Type definition <ContentType ID="0x010100EC124370D330457F8AE8E5EC56DD1FE3" Name="Documents Community" Group="Intranet" Description="Base community documents content type." Inherits="TRUE" Version="0"> <FieldRefs> <FieldRef ID="{F3AD10BD-F2E8-40BD-A923-0B11E264303E}" Name="C_ExpirationDate" DisplayName="ExpirationDate" Required="FALSE"/> </FieldRefs> </ContentType> If I open the settings of a Community documents custom library I can see the CT is pushed correctly to the library. Any ideas? Commented Jun 10, 2013 at 17:33
  • just a comment, the feature of your content type should be activated first before you activate the feature of your listtemplate/listinstance. this is to make sure that the content type is already there before your list is created. So in essense just to make things simplier. separate the content type feature vs the listtemplate/listinstance feature Commented Jun 13, 2013 at 12:53
0

I had the same problem only with a custom Library definition for a document Library defined in CAML. I did some research and the problem is explained here: http://byteloom.blogspot.com/2012/01/custom-upload-form-for-document-library.html. It comes down to the fact that you can't really customize the list toolbar from Schema.xml. SharePoint uses the XLTListViewWebPart web part to display lists and document library and by default use the following XSLT code to display the "new item" or "new document" link button:

<xsl:variable name="Url">
<xsl:choose>
<xsl:when test="List/@TemplateType='119'"> <xsl:value-of select="$HttpVDir"/>/_layouts/CreateWebPage.aspx?List= <xsl:value-of select="$List"/>&RootFolder= <xsl:value-of select="$XmlDefinition/List/@RootFolder"/> </xsl:when>
<xsl:when test="$IsDocLib"> <xsl:value-of select="$HttpVDir"/>/_layouts/Upload.aspx?List= <xsl:value-of select="$List"/>&RootFolder= <xsl:value-of select="$XmlDefinition/List/@RootFolder"/></xsl:when> <xsl:otherwise><xsl:value-of select="$ENCODED_FORM_NEW"/></xsl:otherwise> </xsl:choose> </xsl:variable>

Sorry for the awkward formatting. What I realized is that I couldn't find a trick to make SharePoint see my custom document library as a document library, but I could provide my own xslt code that would add the new document code or whatever it was I wanted for the new document\new item text. I don't like the previous user's solution because I have an event receiver attached that I was afraid wouldn't work correctly if I changed the type to document library. Instructions to modify your schema.xml and add the xslt to your solution are here: http://msdn.microsoft.com/en-us/library/office/ff806164(v=office.14).aspx

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.