Tangible Thoughts

SharePoint, MOSS? and all the other questions

  Home  |   Contact  |   Syndication    |   Login
  858 Posts | 6 Stories | 482 Comments | 2088 Trackbacks

News

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Linky Things

SharePoint Bloggers

SharePoint Related

What I am playing

What I am Reading

With regard to my post on SharePoint field names you might find the following code snippet useful.

// Initialize the list service

Lists listService = new Lists();

listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Get the list schema

XmlNode ndList = listService.GetList("ListName");

// Iterate through each field

foreach (XmlNode ndField in ndList.FirstChild.ChildNodes)

{

string name = string.Empty;

string displayName = string.Empty;

// Obtain the nodes name

name = (string)

ndField.Attributes["Name"].Value;

// Ontain the nodes display name

displayName = (string)

ndField.Attributes["DisplayName"].Value;

Console.WriteLine("Name = {0}\t\tDisplayName = {1}", name, displayName);

}

posted on Friday, July 30, 2004 5:46 AM

Feedback

# re: SharePoint list field names - finder 6/15/2006 6:11 AM Nguyen Minh Hoang
Wow, i real need it.
If i only want to show some fields that have properties Hidden=true.
How do that ?
Thanks a lot ^_^

# re: SharePoint list field names - finder 4/20/2007 11:15 AM Jonathan
Friend in the line "XmlNode ndList = listService.GetList("ListName");" I have the error "Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown." you could help me

# re: SharePoint list field names - finder 8/3/2007 4:36 PM AAron nAAs
Nice tidbit. Thanks for both the call and how you walked through the resulting nodelist.

# re: SharePoint list field names - finder 7/21/2009 1:33 AM Randy Hentz
Works great, here is a vb version
Dim L As New Wss_server.ListsSoapClient
'Dim ListGuid As String = "{BDC0D461-10A0-4973-9B9D-875A76CEEB02}" 'Customer Call Center
Dim ListGuid As String = "{24AF9272-E330-4F93-AD3A-FF6262A34B4E}" 'Field Service
Dim ndList As XmlNode = L.GetList(ListGuid)
txtData.Text = ""
'Iterate through each field
For Each ndfield As XmlNode In ndList.FirstChild.ChildNodes
Dim name As String = String.Empty
Dim displayName As String = String.Empty

' Obtain the nodes name
name = ndfield.Attributes("Name").Value.ToString

' Obtain the nodes display name
displayName = CStr(ndfield.Attributes("DisplayName").Value)
'txtData.Text = txtData.Text + name + "," + displayName + vbCrLf
txtData.Text = txtData.Text + name + vbCrLf
'txtData.Text = txtData.Text + displayName + vbCrLf
Next
L.Close()

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: