Project and List Properties Available from CAML

When you are building a DVWP in SharePoint, there are some project (Web site) and list properties that are available to you directly from CAML that aren’t well-documented, which you can use if you request them directly.  For instance, if you add the following to your CAML <ListProperty Name=”Title” /><ProjectProperty Name=”Title” />, the titles of the project and list are available to you:

<xsl:value-of select=”@ListProperty.Title” />
<xsl:value-of select=”@ProjectProperty.Title” />

These properties are especially useful when you build CrossList DVWPs in order to build up links to items and to display information about them on the page.

Here’s an actual example from a project I worked on:

&lt;View&gt;&lt;Webs Scope="SiteCollection"&gt;&lt;/Webs&gt;&lt;Lists ServerTemplate="104"&gt;&lt;/Lists&gt;&lt;Query/&gt;&lt;ViewFields&gt;&lt;ProjectProperty Name="Title"/&gt;&lt;FieldRef Name="ID"/&gt;&lt;FieldRef Name="Title"/&gt;&lt;FieldRef Name="Body"/&gt;&lt;FieldRef Name="FileDirRef"/&gt;&lt;FieldRef Name="Created"/&gt;&lt;FieldRef Name="Author"/&gt;&lt;FieldRef Name="Expires"/&gt;&lt;FieldRef Name="PermMask"/&gt;&lt;FieldRef Name="ShowOnRootPage"/&gt;&lt;/ViewFields&gt;&lt;/View&gt;

and again in “English”:

<View>
  <Webs Scope="SiteCollection"></Webs>
  <Lists ServerTemplate="104"></Lists>
  <Query/>
  <ViewFields>
    <ProjectProperty Name="Title"/>
    <FieldRef Name="ID"/>
    <FieldRef Name="Title"/>
    <FieldRef Name="Body"/>
    <FieldRef Name="FileDirRef"/>
    <FieldRef Name="Created"/>
    <FieldRef Name="Author"/>
    <FieldRef Name="Expires"/>
    <FieldRef Name="PermMask"/>
    <FieldRef Name="ShowOnRootPage"/>
  </ViewFields>
</View>

ProjectProperty.Property Value
A string that contains the name of a project property listed in the following table.

Name Value
BlogCategoryTitle Category of the current post item.
BlogPostTitle Title of the current post item.
Description Description of the current Web site.
RecycleBinEnabled 1 if the recycle bin is enabled; otherwise, 0.
SiteOwnerName User name of the owner for the current site collection.
SiteUrl Full URL of the current site collection.
Title Title of the current Web site.
Url Full URL of the current Web site.

See ProjectProperty.Property Property for the original MSDN article.

ListProperty.Property Value
A string that contains the name of a property listed in the following table.

Name Value
Created Date and time the list was created.
DefaultViewUrl Server-relative URL of the default list view.
Description Description of the list.
EnableSyndication true if RSS syndication is enabled for the list; otherwise, false.
ItemCount Number of items in the list.
LinkTitle Title linked to list.
MajorVersionLimit For a document library that uses version control with major versions only, maximum number of major versions allowed for items.
MajorWithMinorVersionsLimit For a document library that uses version control with both major and minor versions, maximum number of major versions allowed for items.
RelativeFolderPath Site-relative URL for the list.
Title Title of the list.
ViewSelector View selector with links to views for the list.

See ListProperty.Property Property for the original MSDN article.

Similar Posts

29 Comments

  1. Can you post an example showing where in the CAML these additional references would go? I placed them in the ViewFields but it did not work there.

  2. Hi Marc

    Great bit of info again! I have a DVWP that will display all documents from the site it sits on and below. It will show the ProjectProperty.Title but the ProjectProperty.Url is empty.

    Its CrossList and the Scope is Recursive. Any ideas?

  3. Each property (Title and Url) is specified in the CAML selectcommand.

    gives the title
    is empty (as is SiteUrl)

    David

  4. It stripped out my xsl

    <xsl:value-of select="@ProjectProperty.Title" /> – gives the title
    <xsl:value-of select="@ProjectProperty.Url" /> – is empty

    1. Jasper:

      I just tried to use the ProjectProperty.Title in the Where clause, and I’m not having any luck, either. What are you trying to filter on? There’s probably another viable approach.

      M.

  5. Hi Marc,

    I need to filter CAML results based on the site title. We’ve got several seperate sites setup for customers. I’ve created a Silverlight webpart which uses a webservice to get all unfinished tasks rolled up from all customer sites. I want to be able to filter those based on the customer name which is in the sitename. I can’t use the URL because that only contains the numeric customer code, not the name. Any ideas?

    1. Jasper:

      What Web Service are you calling? Lists.asmx? If you’re using the Web Service, can’t you just filter in your Silverlight code?

      M.

      1. Hi Marc,

        I’m using a custom build web service which executes a SPSiteDataQuery. Of course I can filter out data based on other things, but I want to make sure SPSiteDataQuery keeps performing. And when I first fetch a result set of say 1000 records whilst only needing 25 of those, that will affect performance. So I was hoping I could let SPSiteDataQuery do all the filtering, but I guess that might not be possible.

          1. Hi Marc,

            No, I’m not using an OOTB webservice. I use a custom webservice which I wrote and deployed as a solution. In this webservice, there is a method which uses the SPSiteDataQuery object to query all SharePoint lists on the site (and subsites) at once.

            Because there will be many subsites with many lists and even more items, I need the service to perform at its best.

            1. I think you’d be much better off using Webs.GetAllSubWebCollection, filtering those results for your customer name in the Title, and then going from there. That’s going to be far more efficient. You’ll never grab any items or lists from any sites which are outside your intended targets. I’m not sure that you need to write a custom Web Service at all.

              M.

              1. hi Marc,

                Thanks for the info. I need the custom web service for more things and since I like to have everything in one place I’ll leave it for now. The idea of using GetAllSubwebs is interesting, but I’m not quite sure about performance. Suppose I have 200 sites and 20 of those are retrieved after filtering. I´d then have to fire my query to each of those 20 sites and combine the results. I wonder if that´s truely faster then just querying everything and filtering afterwards. As I´ve read in a few blogs that SPSiteDataQuery is the fastest way to get data from sharepoint, that is when your CAML is ok of course.

                1. You might want to look at what other filter options you have. For instance, if you could filter on WebFullUrl or RootFolder. Since you’re working in code, you don’t really need the CAML properties.

                  M.

  6. I have the same question as Jasper. I’m using a basic client-side call to Webs.asmx. My SOAP envelope contains a CAML query much like a basic Lists.asmx query (Lists works Webs doesn’t).

    I’m assuming I just don’t have the proper CAML. Maybe FieldRef isn’t correct in this case?

    \
    \
    \
    \
    \
    \
    SomeText \
    \
    \
    \
    \
    \

  7. Hi Marc,

    Thanks for this post!

    I’m using Dataview to display a list from a site in several sub sites. I want to filter them by the site title. I tried to use the ProjectProperty.Title but it’s showing the title of the original site and not the sub site, do you have any idea how to show the title of the current site?

    Thank you,
    Shiri

      1. Hi Mark,

        My XSL was as you wrote it in the blog – i added the to the SelectCommand and used it in the RowView template: .

        Anyhow, I used another method – I used GetAllSubWebCollection from webs.asmx, filtered it by URL and used the title.

        Of course your suggestion is easier, but I had to finish the task..

        Thank you,
        Shiri

  8. Hi Mark,

    This works fine.. but for some reason when I have the column in my data view and hook up a filter web part to that column, it doesnt filter correctly. It keeps returning no results.

    Any idea why?

Leave a Reply to Jasper Siegmund Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.