This project is read-only.
SPSiteColumnUsage is a class that can find all references to content types and lists where a site column is beeinig used with in SharePoint site.

This class is similar to the SPContentTypeUsage that is part of the WSS v3.0 object model, but can be used to find site column usage.
  • Methods
    • GetUsages, this method takes a SPField instance as input argument and returns an array of SPSiteColumnUsage objects.
  • Properties
    • Id, the Id of the site column.
    • Scope, the scope of the site column.
    • ContentTypeId, the id of a content type where the site column is in use.
    • IsUrlToList, indicates if the information is about a list or a content type.
    • Url, the server relative to a list where the site column is in use.

usage example
using (SPSite site = new SPSite("http://demosite"))
    using (SPWeb web = site.OpenWeb())
        SPField field = web.Fields.GetFieldByInternalName("Title");

        Console.WriteLine("Field: {0}", fieldName);

        var usage = SPSiteColumnUsage.GetUsages(field);
        foreach (var u in usage)
            Console.WriteLine("Id: {0}", u.Id);
            Console.WriteLine("Scope: {0}", u.Scope);
            Console.WriteLine("ContentTypeId: {0}", u.ContentTypeId);
            Console.WriteLine("IsUrlToList: {0}", u.IsUrlToList);
            Console.WriteLine("Url: {0}", u.Url);

For more info see my weblog

Last edited Feb 8, 2010 at 9:54 PM by Haas, version 8