1

In my custom SharePoint 2010 site definition:

  1. I have a custom list instance in my site definition with multiple views...
  2. I have a page that I want to display one of the views on...
  3. In the page's Elements.xml definition, where can I select to show either the "Correspondence" or "Accounting" views shown in the list instance's Schema.xml below?

XML has been cleaned up for simplicity of reading.

List Instance's Schema.xml

<List Title="Client Documents" Direction="none" Url="Client Documents" BaseType="1" Type="101" BrowserFileHandling="Permissive" EnableContentTypes="TRUE" DisableAttachments="TRUE" Catalog="FALSE" VersioningEnabled="TRUE" SendToLocation="|" ImageUrl="/_layouts/images/itdl.png" xmlns:ows="Microsoft SharePoint" xmlns:spctf="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>...</ContentTypes>
    <Fields>...</Fields>
    <Forms />
    <Views>
      ...
      <View DisplayName="CORE Client - Accounting" BaseViewID="1" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="1" Url="Forms/CORE Client  Accounting.aspx" SetupPath="pages\viewpage.aspx">
        <XslLink>main.xsl</XslLink>
        <Query>
          <Where>
            <Eq>
              <FieldRef Name="ContentType" />
              <Value Type="Computed">Client - Accounting</Value>
            </Eq>
          </Where>
        </Query>
        <ViewFields>...</ViewFields>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Aggregations Value="Off" />
      </View>
      <View DisplayName="CORE Client - Correspondence" BaseViewID="1" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="1" Url="Forms/CORE Client  Correspondence.aspx" SetupPath="pages\viewpage.aspx">
        <XslLink>main.xsl</XslLink>
        <Query>
          <GroupBy Collapse="TRUE" GroupLimit="30">
            <FieldRef Name="Client_x0020_Correspondence_x0020_Type" />
          </GroupBy>
          <Where>
            <Eq>
              <FieldRef Name="ContentType" />
              <Value Type="Computed">Client - Correspondence</Value>
            </Eq>
          </Where>
        </Query>
        <ViewFields>...</ViewFields>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Aggregations Value="Off" />
      </View>
      ...
    </Views>
  </MetaData>
</List>

Module's Elements.xml

<File Url="ClientDocumentsCorrespondence.aspx" Path="default.aspx" Type="GhostableInLibrary" >
    <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PLClientDocuments.aspx" />
    <Property Name="Title" Value="GASOP Client Documents - Correspondence" />
    <Property Name="ContentType" Value="Welcome Page" />
    <AllUsersWebPart WebPartOrder="0" WebPartZoneID="zone1">...</AllUsersWebPart>
    <AllUsersWebPart WebPartOrder="1" WebPartZoneID="zone1">...</AllUsersWebPart>
    <View List="Client Documents"
        DisplayName=""
        Url=""
        DefaultView="FALSE"
        BaseViewID="1"
        Type="HTML"
        WebPartOrder="0"
        WebPartZoneID="zone2"
        ContentTypeID="0x"
        ID="g_4d8c86ec_b324_4f6a_a2e9_ba1a36466c68"
        Hidden="TRUE">
    <![CDATA[<webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
            <metaData>
            <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
            </metaData>
            <data>
            <properties>...</properties>
            </data>
        </webPart>
    </webParts>]]>
    </View>
</File>
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Dave
  • 45
  • 3
  • 8

1 Answers1

1

its seem to on schema.xml you have creating two views but both have same BaseViewID. you must be unique BaseViewID for each view. 1 is the ID of the AllItems view(Default View).

Refer to this post: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/52e45ddd-73a8-400f-890c-323a0eaaeccb

copy-paste default view and giv unique Id of BaseViewID.

than on your Module's Elements.xml

  <View List="Lists/Client Documents" BaseViewID="<<Your View Unique ID>>"  DisplayName="Client Documents" Name="Client Documents" RecurrenceRowset="TRUE" WebPartZoneID="Main" WebPartOrder="0">
      <![CDATA[
          <webParts>
              <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                  <metaData>
                      <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                  </metaData>
                  <data>
                      <properties>
                          <property name="Title">Invoice Approved</property>
                          <property name="AllowConnect" type="bool">True</property>
                          <property name="AllowClose" type="bool">False</property>
                      </properties>
                  </data>
              </webPart>
          </webParts>
      ]]>
    </View>

Please read for more details : http://blog.qumsieh.ca/2010/09/01/sharepoint-2010-schema-xml-onet-xml-and-toolbar-type/

Community
  • 1
  • 1
Jignesh Rajput
  • 3,538
  • 30
  • 50
  • If I make the BaseViewID unique, I get the following error: http://siteURL/Client Documents/Forms/Upload.aspx - An unexpected error has been encountered in this Web Part. Type: Microsoft.SharePoint.WebPartPages.ListFormWebPart, Error: Cannot complete this action. Please try again – Dave Mar 28 '13 at 06:56
  • something wrong on `schema.xml` or `module.xml`.Please check properly to everything valid or not.check ULS Viewer for more detail error. – Jignesh Rajput Mar 28 '13 at 07:38