title: Retrieve metadata column fields
body: <p>I need to programmatically retrieve the columns in a Sharepoint document library, in order to set file properties externally to Sharepoint.</p>
  
  <p>I've found that setting the metadata property is not hard as long as you already know the name of the column, which I cannot expect users to input themselves.</p>
  
  <p>As it does not seem possible to do this through the Sharepoint Web Services I have created my own custom web service so I have access to the Client Object Model.</p>
  
  <p><img src="https://i.stack.imgur.com/zRuP4.png" alt="List Custom Columns"></p>
  
  <p>Using this code I am able to retrieve the custom columns I have created, however I am not able to distinguish between the ones editable in the item properties section (picture above) and those which aren't.</p>
  
  <pre><code>SPList list = web.Lists[specificList];
  foreach (SPField field in list.Fields)
  {
      if (!field.Hidden)
      {
          var title = field.Title;
          var description = field.Description;
          var parentList = field.ParentList;
  
          var references = field.FieldReferences; // contains names of fields referenced in computed fields
  
          if (references != null)
          {
              foreach (string reference in references)
              {
                  var test = parentList.Fields.GetField(reference);
              }
          }
      }
  }
  </code></pre>
  
  <p>I get extra properties such as:</p>
  
  <ul>
  <li>Copy Source </li>
  <li>Content Type</li>
  <li>Checked Out To </li>
  <li>Checked In Comment </li>
  <li>Type </li>
  <li>File</li>
  <li>Size </li>
  <li>Edit </li>
  <li>Version </li>
  <li>Source Version </li>
  <li>Source Name</li>
  </ul>
  
  <p>I have also tried retrieving the column fields from the SPFolder item, but again this returns many extra properties and is even less filterable.</p>
  
  <pre><code>foreach (SPListItem folderItem in list.Folders)
  {
      SPFolder folder = folderItem.Folder;
      System.Collections.Hashtable oHashtable = folder.Properties;
      System.Collections.ICollection collKeys = oHashtable.Keys;
  
      foreach (var key in collKeys)
      {
          string keyName = key.ToString();
      }
  }
  </code></pre>
  
  <p>Is there a standard way to retrieve the column fields I need? Or will I have to manually exclude the defaults ones such as "Checked out to"?</p>