Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

SharePoint 2007 introduced content-types to template standard record definitions and re-use them across lists, such as Task, Issue, or even Folder. Multiple such content-types can be set associated to a single list. A folder is a content-type as well, and it can not only have child items/files within it but also have extended columns just like any item. This allows interesting scenario's where-by instead of using Lookups to setup relationship of items spread across lists one can implicitly set master-detail relationship on items within same lists.

I want to share how can you show the number of items within such folder (or master item!) without actually opening it. This is often useful when you want to give a view to users or have compute column at Master level without going deep into Details level.

ItemChildCount

This is a column in SharePoint database that keeps track of child items to a folder. When building a custom list definition or to an existing list, you can update list schema to include custom Field that is a lookup to ItemChildCount. Syntax is:

   1:  <Field ID="{REPLACE YOUR GUID HERE}"
   2:      Name="ItemChildCount" 
   3:      DisplayName="# of Items"
   4:      DisplaceOnUpgrade="TRUE" 
   5:      SourceID="http://schemas.microsoft.com/sharepoint/v3" 
   6:      StaticName="ItemChildCount" 
   7:      Group="_Hidden" 
   8:      ReadOnly="TRUE" 
   9:      Filterable="FALSE" 
  10:      Sortable="FALSE" 
  11:      Hidden="FALSE" 
  12:      Type="Lookup" 
  13:      List="Docs" 
  14:      FieldRef="ID" 
  15:      ShowField="ItemChildCount"
  16:      JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" />

Above should be included in Schema.xml of your list definition, or you can update existing list by object model. If you do not have access to deploy code on your SharePoint site, say in a corporate Intranet setup, you can still update your custom list schema by Web Service by adding above field.

In a future post I'll share some details on enabling various scenario's by use of multiple content-types within same list, and its usability benefits on SharePoint sites.

-- Sharad

Published Friday, June 27, 2008 12:37 AM by eJugnoo

Comments

# Links (6/29/2008) &laquo; Steve Pietrek - Everything SharePoint

Pingback from  Links (6/29/2008) &laquo; Steve Pietrek - Everything SharePoint

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Wednesday, July 30, 2008 1:41 PM by Joseph Amen

Shara, I'm trying to implement this column in the default doclib. Is there anything I have to do besides add this to the schema.xml ?

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Friday, January 23, 2009 6:45 AM by Sharad

You have to manually add the new column to your View. New column is only available via View and can't be removed from UI.

--Sharad

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Thursday, March 12, 2009 6:30 AM by rakesh kolloju

Its not at all working

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Thursday, March 12, 2009 12:22 PM by Vijay

Hi

Great Post !!

Works fatastic for me.

I also tried using FolderChildCount column in the table but getting an exception there as "can not complete this action".

Any ideas?

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Thursday, March 12, 2009 12:22 PM by rakesh kolloju

sorry its working, can you tell how to get the FolderItemCount ?

help is appreciated

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Wednesday, August 19, 2009 4:08 PM by Bharath

Can anybody guide me how to do this exactly with steps or screenshots..

Thanks in advance

# re: Showing Child-Items Count in hierarchical SharePoint Lists with multiple content-types

Thursday, August 20, 2009 9:37 AM by Bharath

Hi Folks,

I got this working on my list and am trying to get this done on my DocLib/Schema.Xml but though i notice that the number of items displayed is just the number of items in that folder and the sum doesnt include the items inside the sub-folder or the sub-sub folders,

Anyways to know all the items inside the folder sub folder etc.. as a column in the uppermost level.

Leave a Comment

(required) 
(required) 
(optional)
(required)