Wednesday, April 23, 2014

BaseViewID in Sharepoint List View Element

Hey,

I have created a SharePoint List named "Tasks" using CAML approach - For the same I had created a dummy Tasks List and took the Schema of the list using SharePoint Manager tools.

Note that within my dummy Tasks List, I had created 2 customs views however when I looked carefully at the Schema the BaseViewID was always 1 tho it was a custom view.

I deployed my List and I wanted to show the View on my Default page using ListViewWebPart but when I was mapping my BaseViewID it was not showing the right View.

It took me hours to figure out that SharePoint was referring to the Tasks Schema within the below path - why ? may be because my list name was Tasks... My customer wanted to use the same name and I had to find out some solutions...
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\TasksList\Tasks
On my custom view I gave a different unique ID mentioned by Brian Bedard but it didn't work...

Finally, I decided to re-create the List Instance with the same name "Tasks" but this time using the assistant of Visual Studio which provide a nice interface to create Views and there it worked - It created the custom views with different BaseViewID.

Here is the Elements.xml of the Page (Module) if it can help anyone

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="PageModule" Url="$Resources:cmscore,List_Pages_UrlName;">
    <File Url="defaultLeaf.aspx" Type="GhostableInLibrary" Path="PageModule\defaultLeaf.aspx" IgnoreIfAlreadyExists="TRUE" >
      <Property Name="Title" Value="Home" />
      <Property Name="IncludeInGlobalNavigation" Value="FALSE" />
      <Property Name="ContentType" Value="Welcome Page" />
      <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Leaf.Layout.aspx, Leaf Web Part Page" />
      <AllUsersWebPart WebPartZoneID="Header" WebPartOrder="0">
        <![CDATA[
           <?xml version="1.0" encoding="utf-8"?>
            <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
              <Title>Welcome</Title>
              <FrameType>None</FrameType>
              <Description>Welcome</Description>
              <IsIncluded>true</IsIncluded>
              <ZoneID>Left</ZoneID>
              <PartOrder>1</PartOrder>
              <FrameState>Normal</FrameState>
              <Height />
              <Width />
              <AllowRemove>true</AllowRemove>
              <AllowZoneChange>true</AllowZoneChange>
              <AllowMinimize>true</AllowMinimize>
              <AllowConnect>true</AllowConnect>
              <AllowEdit>true</AllowEdit>
              <AllowHide>true</AllowHide>
              <IsVisible>true</IsVisible>
              <DetailLink />
              <HelpLink />
              <HelpMode>Modeless</HelpMode>
              <Dir>Default</Dir>
              <PartImageSmall />
              <MissingAssembly>An error has occured - Please contact your system administrator.</MissingAssembly>
              <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
              <IsIncludedFilter />
              <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
              <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
              <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
              <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
                <h2>Welcome to your Site Template</h2>
              </Content>
              <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
              </WebPart>
              ]]>
      </AllUsersWebPart>
      <View List="Lists/News" DisplayName="" Url="" DefaultView="FALSE" BaseViewID="0" Type="HTML" WebPartOrder="1" WebPartZoneID="Header" ContentTypeID="0x">
        <![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="InitialAsyncDataFetch" type="bool">False</property>
        <property name="ChromeType" type="chrometype">Default</property>
        <property name="Title" type="string" />
        <property name="Height" type="string" />
        <property name="CacheXslStorage" type="bool">True</property>
        <property name="ListDisplayName" type="string" null="true" />
        <property name="AllowZoneChange" type="bool">True</property>
        <property name="AllowEdit" type="bool">True</property>
        <property name="XmlDefinitionLink" type="string" />
        <property name="DataFields" type="string" />
        <property name="Hidden" type="bool">False</property>
        <property name="ListName" type="string">{$ListId:Lists/Announcements;}</property>
        <property name="NoDefaultStyle" type="string" />
        <property name="AutoRefresh" type="bool">False</property>
        <property name="ViewFlag" type="string">8388621</property>
        <property name="Direction" type="direction">NotSet</property>
        <property name="AutoRefreshInterval" type="int">60</property>
        <property name="AllowConnect" type="bool">True</property>
        <property name="Description" type="string" />
        <property name="AllowClose" type="bool">True</property>
        <property name="ShowWithSampleData" type="bool">False</property>
        <property name="ParameterBindings" type="string">  &lt;ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/&gt;
            &lt;ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/&gt;
            &lt;ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/&gt;
            &lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/&gt;
            &lt;ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /&gt;
       &lt;ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /&gt;
            &lt;ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /&gt;
            &lt;ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /&gt;&lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,NoAnnouncements)" /&gt;&lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,NoAnnouncementsHowTo)" /&gt;&lt;ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,idHomePageNewAnnounce)" /&gt;&lt;ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,MoreAnnouncements)" /&gt;&lt;ParameterBinding Name="ByText" Location="Resource(wss,2000)" /&gt;</property>
        <property name="Xsl" type="string" null="true" />
        <property name="CacheXslTimeOut" type="int">86400</property>
        <property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
        <property name="ListUrl" type="string" null="true" />
        <property name="DataSourceID" type="string" />
        <property name="FireInitialRow" type="bool">True</property>
        <property name="ManualRefresh" type="bool">False</property>
        <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
        <property name="ChromeState" type="chromestate">Normal</property>
        <property name="AllowHide" type="bool">True</property>
        <property name="PageSize" type="int">-1</property>
        <property name="SampleData" type="string" null="true" />
        <property name="BaseXsltHashKey" type="string" null="true" />
        <property name="AsyncRefresh" type="bool">False</property>
        <property name="HelpMode" type="helpmode">Modeless</property>
        <property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">$ListId:Lists/Announcements;</property>
        <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
        <property name="AllowMinimize" type="bool">True</property>
        <property name="TitleUrl" type="string">/sites/TeamSite/Lists/Announcements</property>
        <property name="CatalogIconImageUrl" type="string" />
        <property name="DataSourcesString" type="string" />
        <property name="GhostedXslLink" type="string">main.xsl</property>
        <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
        <property name="DisplayName" type="string" />
        <property name="UseSQLDataSourcePaging" type="bool">True</property>
        <property name="Width" type="string" />
        <property name="ExportMode" type="exportmode">All</property>
        <property name="XslLink" type="string" null="true" />
        <property name="ViewContentTypeId" type="string" />
        <property name="HelpUrl" type="string" />
        <property name="XmlDefinition" type="string">&lt;View Name="{A7CDF12B-A952-4931-8E82-3A7B3170D5ED}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="" Url="/sites/TeamSite/default.aspx" Level="1" BaseViewID="0" ContentTypeID="0x"&gt;&lt;Query&gt;&lt;Where&gt;&lt;Or&gt;&lt;IsNull&gt;&lt;FieldRef Name="Expires"/&gt;&lt;/IsNull&gt;&lt;Geq&gt;&lt;FieldRef Name="Expires"/&gt;&lt;Value Type="DateTime"&gt;&lt;Today/&gt;&lt;/Value&gt;&lt;/Geq&gt;&lt;/Or&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name="Modified" Ascending="FALSE"/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name="LinkTitleNoMenu" Explicit="TRUE"/&gt;&lt;FieldRef Name="Body" Explicit="TRUE"/&gt;&lt;FieldRef Name="Author" Explicit="TRUE"/&gt;&lt;FieldRef Name="Modified" Explicit="TRUE"/&gt;&lt;FieldRef Name="Attachments" Explicit="TRUE"/&gt;&lt;/ViewFields&gt;&lt;RowLimit&gt;5&lt;/RowLimit&gt;&lt;Toolbar Type="Freeform"/&gt;&lt;/View&gt;</property>
        <property name="Default" type="string" />
        <property name="TitleIconImageUrl" type="string" />
        <property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
        <property name="SelectParameters" type="string" />
      </properties>
    </data>
  </webPart>
</webParts>]]>
      </View>
      <View List="Lists/Tasks" DisplayName="My Active Task" Name="My Active Task"  WebPartZoneID="Header"  BaseViewID="9" Type="HTML" WebPartOrder="2">
        <![CDATA[
             <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                  <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                  <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
                  <Title>My Active Task</Title>
             </WebPart>
      ]]>
      </View>
     
     
      <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
        <![CDATA[
        <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
          <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
          <TypeName>Microsoft.SharePoint.WebPartPages.MembersWebPart</TypeName>
          <Title>Site Manager</Title>
          <Description>Use the Members Web Part to see a list of the site members and their online status.</Description>
          <FrameType>Standard</FrameType>
          <IsVisible>true</IsVisible>
        </WebPart>
      ]]>
      </AllUsersWebPart>
      <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="2">
        <![CDATA[
        <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
          <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
          <TypeName>Microsoft.SharePoint.WebPartPages.MembersWebPart</TypeName>
          <Title>Site Members</Title>
          <Description>Use the Members Web Part to see a list of the site members and their online status.</Description>
          <FrameType>Standard</FrameType>
          <IsVisible>true</IsVisible>
        </WebPart>
      ]]>
      </AllUsersWebPart>
    </File>
  </Module>
</Elements>
    

No comments:

Post a Comment