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 have create a custom list definition, with a content type.

In the schema.xml, I'd like to define two views :

  • All items (the default one, generated by Visual Studio)
  • My items (the same view with a filter based on the user id)

When I deploy my list, the two views are actually created, bu the filter I define for the second one disappeared.

Here is the filter I use :

    <Query>
      <OrderBy>
        <FieldRef Name="Modified"
                  Ascending="FALSE">
        </FieldRef>
      </OrderBy>
      <Where>
        <Eq>
          <FieldRef Name="AssignedTo" />
          <Value Type="Integer">
            <UserID />
          </Value>
        </Eq>
      </Where>
    </Query>

What is missing ? If I use SPD to create the filter after the deployment, it generates exactly this query.

Don't know if it can help, but here is the whole view definition :

  <View BaseViewID="1"
        Type="HTML"
        WebPartZoneID="Main"
        DisplayName="My messages"
        DefaultView="TRUE"
        MobileView="True"
        MobileDefaultView="True"
        SetupPath="pages\viewpage.aspx"
        ImageUrl="/_layouts/images/announce.png"
        Url="MyMessages.aspx">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">mycustomxsl.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ParameterBindings>
      <ParameterBinding Name="NoAnnouncements"
                        Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo"
                        Location="Resource(wss,noXinviewofY_DEFAULT)" />
    </ParameterBindings>
    <ViewFields>
      <FieldRef Name="Attachments">
      </FieldRef>
      <FieldRef Name="LinkTitle">
      </FieldRef>
      <FieldRef Name="Modified">
      </FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Modified"
                  Ascending="FALSE">
        </FieldRef>
      </OrderBy>
      <Where>
        <Eq>
          <FieldRef Name="AssignedTo" />
          <Value Type="Integer">
            <UserID />
          </Value>
        </Eq>
      </Where>
    </Query>
  </View>

[Edit]: I'm a bit confused with the <View BaseType="1"> attribute. As I want to keep the AllItems view, I have now two views with the same base type. What is exactly the purpose of this attribute ? Am I right to think I can have as many as required view with the same basetype ?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The BaseViewID must be unique for each view. 1 is the ID of the AllItems view, which has no filters, that's why you can't see your filters.

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

share|improve this answer

BaseViewID is a confusing name. It should have been named just ViewID which is what it exactly is.

You BaseViewID must be unique for each view in a list. Try giving the BaseViewID as 3 to your "My Items" View.

share|improve this answer

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.