SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anyone tell me how can I get the custom fields from a sharepoint list? I don't want to get all the fields like hidden, just the custom ones or the ones in the default view. The end result will be to save the schemaxml for each field in an xml file.

I am trying to do it like this:

SPfieldCollection fields = list.DefaultView.ViewFields 
foreach(SPField field in fields) 

Powershell or C# will be very helpful. Thank you

share|improve this question
What do you consider "default" fields? Ones that are not created by the list template? If I'm right, you should try to parse the originating list template and diff the found fields. – Steve B Jul 20 '12 at 13:12
You have to know the Fields Name and if they are custom – Muhammad Raja Jul 20 '12 at 13:59

You are asking for three different things here. They can all be done, you just need to refine your requirement a little. You can certainly 1) get all the non-hidden fields, 2) get all the fields that are different from the list template, and 3) get all the fields from a particular view. First decide what constitutes a "custom field", and proceed from there.

Whether you need to do this for one specific list or dynamically across all the lists in a site collection(for example) also will play into your solution design.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.