Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've got a custom site definition with a list definition + list instance in it. In the schema.xml for the list, I tried adding multiple views for the list. The problem I have is that although the custom views are being deployed, some properties seem to be ignored for some reason.

For example; I have defined some other ViewFields to be shown in one of the non-default views. But after deployment, that custom view shows exactly the same columns as the default view has. Same goes for the Query, that isn't deployed as well.

Here's my view def:

<View Name="{5BB1D385-0E92-42D0-8348-8E81F90D2688}" MobileView="TRUE" Type="HTML" 
        DisplayName="Verzonden orders" Url="VerzondenOrders.aspx" 
        BaseViewID="1" ImageUrl="/_layouts/images/generic.png"
        SetupPath="pages\viewpage.aspx">
    <ViewFields>
      <FieldRef Name="Attachments" />
      <FieldRef Name="Ordernummer" />
      <FieldRef Name="Commissie" />
      <FieldRef Name="Datum_x0020_besteld" />
      <FieldRef Name="Datum_x0020_verzonden" />
      <FieldRef Name="Order_x0020_status" />
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Ordernummer" />
      </OrderBy>
      <Where>
        <Eq>
          <FieldRef Name="Order_x0020_status" />
          <Value Type="Text">Verzonden</Value>
        </Eq>
      </Where>
    </Query>
    <RowLimit Paged="TRUE">30</RowLimit>
    <XslLink Default="TRUE">main.xsl</XslLink>
    <Toolbar Type="Standard" />
  </View>

Who can help me out?

share|improve this question
    
I can't say I've seen a great number of these (sheltered life, I know), but I haven't seen a GUID in the Name attribute before... –  Stuart Pegg Apr 21 '11 at 10:40
add comment

4 Answers

up vote 1 down vote accepted

Do you have a unique BaseViewID for every view?

I noticed that in your sample view that the Url attribute is VerzondenOrders.aspx and the BaseViewID attribute is 1. Usually 1 is the BaseViewID of AllItems.aspx. If you copy and pasted your custom views from AllItems.aspx, you need to make sure to change the BaseViewID in addition to the URL and DisplayName.

I suppose that it is possible that if all your views have a BaseViewID of 1 that SharePoint is using the ViewFields definition from the first entry (AllItems.aspx), which could explain the behavior you are seeing.

share|improve this answer
    
Hello Rich, sounds plausible. But 'BaseView' sounds like a 'ViewType' kind of thing; so that why I didn't change it. I'll try changing it to see what happens, thanks. –  Jasper Apr 26 '11 at 14:28
    
That was it man, thanks so much. Stupid little error which I overlooked :) –  Jasper Apr 26 '11 at 14:50
add comment

Not sure if you have manually created your xml, but one way to find errors is to design the list through the browser first, then save the site as a template through site setting (/_layouts/savetmpl.aspx), download the wsp from the solution gallery, extract the files from it, and compare your schema.xml against the schema.xml in the wsp.

share|improve this answer
    
you beat me to it :-) –  Anders Rask Apr 21 '11 at 10:15
    
I'll try that, thanks. –  Jasper Apr 21 '11 at 13:07
    
Ok. So I corrected the list in the browser. Exported the site to WSP and imported is. Copied the exact view definition from the export into my project and tried again. Result is still the same: it just doesn't work. I get my first view 2 times, the second definition is ignored. –  Jasper Apr 21 '11 at 13:16
    
Maybe you should copy the whole list definiton to avoid inconsistencies between fieldnames in list and fieldrefs in view. Am pretty sure there is something funny going on in your xml. –  Jaap Vossers Apr 26 '11 at 8:41
add comment

How did you create the view? Did you export the schema from an existing site or copy an existing view? I recommend exporting either site or list as template, open them in Visual Studio (import site) and get the view from there.

Also do the fields exist in the content type?

share|improve this answer
    
Yes, the fields exist. I copied the default view (which is deployed correctly) and swapped one field and the where clause of the query. When I open up SPD and edit the viewpage, I can paste in my definition from schema.xml and it works ok :S –  Jasper Apr 21 '11 at 13:05
    
Do try to build everythibg as you want it and export as template. Then i import i to vs project –  Anders Rask Apr 21 '11 at 22:33
add comment

Do the columns defined in the ViewFields exist in the list definition. And are these columns created when the list is created?

share|improve this answer
    
Yes and Yes, since it all works fine for the default view. It's just the additional custom view which isn't deploying properly. –  Jasper Apr 21 '11 at 13:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.