views:

266

answers:

3

Hi all:

I have a list of fields/columns that comprises of Sharepoint specific fields/columns, my own custom fields/columns, and a bunch of custom fields/columns created by someone else (which I dont know what they are yet). My goal is to get the list of the fields/columnns created by that someone else.

My first hurdle lies in how to tell which ones are from Sharepoint. So I was wondering is there any way to programmatically retrieve a list of Sharepoint Specific fields/columns?

Thanks.

A: 

Try the List Data Retrieval web service provided by SharePoint.

http://<site>/_vti_bin/DspSts.asmx

I don't have SharePoint on a machine at home to test this myself, but I would try the "Fields" class. I test this out myself at work tomorrow.

Documentation: http://msdn.microsoft.com/en-us/library/ms774413.aspx

Robert Williams
+1  A: 

It's not programmatically, but in the 12 Hive of your server, under Template/Features/fields is a fieldswss.xml which I believe contains all of the standard SharePoint fields.

A more programmatic approach would be to iterate through the Site Columns and perform some check. For example,

List<string> retVal = new List<string>();
using (SPSite site = new SPSite("urlofsite")) 
{
    using (SPWeb web = site.OpenWeb())
    {
        List<string> spColGroups = new List<string>() { "Base Columns", "Core Contact and Calendar Columns", "Core Document Columns", "Core Task and Issue Columns", "Extended Columns" }

        foreach (SPField field in web.Fields)
        {
            if (spColGroups.Contains(field.Group))
            {
                retVal.Add(field.Title);
            }
        }
    }
}

The list retVal would then contain the names of all site columns which belong to the standard SharePoint site column groups (at least, for WSS. I don't know about MOSS). My own personal practice (I don't know if this is common but I think it is a very wise move) is to always make my own custom columns in a different group than the default SharePoint ones, so this will only get the SharePoint columns. If this is not the case for you, you'll have to devise a more useful check for your situation. I hope that, if this doesn't solve your problem, that it at least helps you get on the right track.

ccomet
A: 

This might not be an exhaustive list, but the SPBuiltInFieldId class would be a good place to start.

Rich Bennema