SharePoint Config

Ari Bakker's thoughts on customising and configuring SharePoint

VS2010 list definition template missing file dialog view

with 10 comments

The problem

When you open or save Office documents to standard SharePoint document libraries a custom view is displayed in the file dialog window. This is rendered via a hidden view that is part of the list definition and allows you to navigate the folder structure and use custom metadata to sort the documents. The screen show below shows the Save As dialog from Word but similar views appear when opening or saving from Outlook, Excel or other Office applications.

office-file-dialog-sharepoint-doc-library-view

I’ve noticed that when you use the Visual Studio 2010 SharePoint List Definition template to create a custom document library definition the view does not get displayed correctly. The view header is displayed but there is no way to save a document in a specific folder or even see the documents that are currently in the library.

office-file-dialog-sharepoint-doc-library-custom-view

This happens with both the ‘List Definition’ and the ‘List Definition’ From Content Type Visual Studio SharePoint 2010 list definition templates.

visual-studio-2010-list-definition

The solution

To find out why this was occurring I compared the schema files of a list definition created by the Visual Studio templates with the out-of-the-box document library definition. One section in particular stood out – the View element with DisplayName=”$Resources:core,File_Dialog_View;” was missing the CAML that renders this view. The differences are shown below:

Custom Document Library created with Visual Studio 2010 list definition template

<View BaseViewID="2" Type="HTML" FileDialog="TRUE" TabularView="FALSE" DisplayName="$Resources:core,File_Dialog_View;" Hidden="TRUE" Path="filedlg.htm" ModerationType="Moderator">
  <Toolbar Type="Standard" />
  <ViewFields>
    <FieldRef Name="DocIcon">
    </FieldRef>
    <FieldRef Name="BaseName">
    </FieldRef>
    <FieldRef Name="Editor" TextOnly="TRUE">
    </FieldRef>
    <FieldRef Name="Modified" TextOnly="TRUE">
    </FieldRef>
  </ViewFields>
  <Query>
    <OrderBy>
      <FieldRef Name="FSObjType" Key="Primary" />
      <FieldRef Name="FileLeafRef" />
    </OrderBy>
  </Query>
</View>

Default Document Library

<View BaseViewID="2" Type="HTML" FileDialog="TRUE" TabularView="FALSE" DisplayName="$Resources:core,File_Dialog_View;" Hidden="TRUE" Path="filedlg.htm" ModerationType="Moderator">
        <ViewHeader>
          <SetVar Name="FileDialog">1</SetVar><HTML><![CDATA[
            <table id="FileDialogViewTable" width="100%" style="cursor: default;" border="0" rules="rows" cellspacing="0" cellpadding="2">
                <tr>
        ]]></HTML>
          <Fields><HTML><![CDATA[<th class="ms-vh2-nofilter">]]></HTML>
            <Field /><HTML><![CDATA[</th>]]></HTML>
          </Fields><HTML><![CDATA[</tr>]]></HTML>
        </ViewHeader>
        <ViewBody>
          <SetVar Name="FileDialog">1</SetVar>
          <IfEqual>
            <Expr1>
              <GetVar Name="AlternateStyle" />
            </Expr1>
            <Expr2>ms-alternating</Expr2>
            <Then>
              <SetVar Scope="Request" Name="AlternateStyle">
              </SetVar>
            </Then>
            <Else>
              <SetVar Scope="Request" Name="AlternateStyle">ms-alternating</SetVar>
            </Else>
          </IfEqual>
          <Switch>
            <Expr>
              <LookupColumn Name="FSObjType" />
            </Expr>
            <Case Value="1"><HTML>&lt;TR fileattribute=folder ID="</HTML>
            </Case>
            <Default><HTML>&lt;TR fileattribute=file ID="</HTML>
            </Default>
          </Switch>
          <Field Name="EncodedAbsUrl" /><HTML><![CDATA[" class="]]></HTML>
          <GetVar Name="AlternateStyle" /><HTML><![CDATA[" onmousedown="selectrow()" onclick="selectrow()">]]></HTML>
          <Fields><HTML><![CDATA[<td class="ms-vb" style="padding-left: 4px">]]></HTML>
            <FieldSwitch>
              <Expr>
                <Property Select="Type" />
              </Expr>
              <Case Value="User">
                <LookupColumn HTMLEncode="TRUE" />
              </Case>
              <Default>
                <FieldSwitch>
                  <Expr>
                    <Property Select="Name" />
                  </Expr>
                  <Case Value="CheckoutUser">
                    <Field HTMLEncode="TRUE" />
                  </Case>
                  <Default>
                    <Field />
                  </Default>
                </FieldSwitch>
              </Default>
            </FieldSwitch><HTML><![CDATA[</td>]]></HTML>
          </Fields><HTML><![CDATA[</tr>]]></HTML>
        </ViewBody>
        <ViewFooter><HTML><![CDATA[</table>]]></HTML>
        </ViewFooter>
        <ViewEmpty>
          <SetVar Name="FileDialog">1</SetVar><HTML><![CDATA[
            <table id="FileDialogViewTable" width="100%" style="cursor: default;" border="0" rules="rows" cellspacing="0" cellpadding="2">
                <tr>
        ]]></HTML>
          <Fields>
            <Switch>
              <Expr>
                <Property Select="Name" />
              </Expr>
              <Case Value="FileLeafRef">
              </Case>
              <Default><HTML><![CDATA[<th class="ms-vh2-nofilter">]]></HTML>
                <Field /><HTML><![CDATA[</th>]]></HTML>
              </Default>
            </Switch>
          </Fields><HTML><![CDATA[</tr></table>]]></HTML><HTML><![CDATA[<table width="100%" border="0" rules="rows"><tr>]]></HTML><HTML><![CDATA[<td class="ms-vb">]]></HTML><HTML>$Resources:core,noDocOfSpecType;</HTML><HTML><![CDATA[</td></tr></table>]]></HTML>
        </ViewEmpty>
        <ViewFields>
          <FieldRef Name="DocIcon">
          </FieldRef>
          <FieldRef Name="BaseName">
          </FieldRef>
          <FieldRef Name="Editor" TextOnly="TRUE">
          </FieldRef>
          <FieldRef Name="Modified" TextOnly="TRUE">
          </FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="FSObjType" Key="Primary" />
            <FieldRef Name="FileLeafRef" />
          </OrderBy>
        </Query>
      </View>

Thankfully adding the missing section (from the start of the ViewHeader to the end of the ViewEmpty element) into the faulty list definition fixed the problem (and was able to be applied to existing libraries via a solution package upgrade) but it is something to be aware of as it is a loss of functionality. As a side note if you want to change the fields that are displayed in the Office file dialog views for custom list definitions this is where to do it!

Post to Twitter Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Written by Ari Bakker

February 15th, 2011 at 9:44 pm

10 Responses to 'VS2010 list definition template missing file dialog view'

Subscribe to comments with RSS or TrackBack to 'VS2010 list definition template missing file dialog view'.

  1. Hi,

    I have been reading your article, and I have to admit it is very interesting.

    I am quite desperate in doing something similar. I want to create my own view in the “Save As” dialog so I can remove the “modify” field and add an extisting one.

    Can you point me in the right direction of how to do that?

    Thanks a lot in advance.

    Gabriel Renom

    Gabriel

    16 Jun 11 at 4:01 pm

  2. @Gabriel if you create a new list definition using Visual Studio 2010 you can customise the fields that are shown in the Office save as dialog by editing the ViewFields element of the View with BaseViewID=”2″ (in the schema.xml file). This is the same View mentioned in this article. For example you could removed the FieldRef Name=”Modified” element to remove the modified date and adding a FieldRef with the name of the field you want to add will achieve the result you are after. Let me know if you want more details on this.

    Ari Bakker

    16 Jun 11 at 5:30 pm

  3. Very good article, thank you, you saved my day 🙂

    Mohammed

    1 Nov 11 at 8:46 am

  4. Are you deploying this as a Farm or Sandboxed solution?

    I can’t get this to work at all Sandboxed. Just gives me a 410 “The webpage no longer exist” in the explorer. As a Farm solution this solves it so thank for sharing!

    Marie

    25 Nov 11 at 1:26 pm

  5. @Marie when I wrote this I was testing using Farm solution but when I try with a Sandboxed solution I get the same error. Let me know if you find a solution to this

    Ari Bakker

    25 Nov 11 at 2:20 pm

  6. […] existing documents in the library, which leads to confusion from end users. The issue is documented here, and can be relatively straightforward to fix, provided the problem is spotted during the […]

  7. Thank you, I have been working on this for a couple of days.

    Chris

    8 Mar 13 at 11:47 am

  8. […] Studio was putting out…was going to trouble shoot further and write up, then noticed that this has all been written up already by Ari Bakker. The article includes all the gory details and the fix. Nice […]

  9. […] When you use the Visual Studio 2010 SharePoint List Definition template to create a custom document library definition the view does not get displayed correctly described here […]

  10. You could also remove View=2 from List definition. That would also work.

    Igor

    17 Nov 14 at 3:22 pm

Leave a Reply

*