Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

What is a foolproof method of getting a list of fields that are editable by the user from the UI in a SharePoint list.

I tried getting the ShowInEditForm property, but in many cases, it returns NULL.

I tried this condition check,

listfield.Hidden != true && listfield.ReadOnlyField != true && listfield.FromBaseType != true

but that includes Attachment and Content Type Fields

share|improve this question
add comment

3 Answers 3

You can add this to your code

listfield.Type != SPFieldType.Attachments

Hope this helps

share|improve this answer
add comment

You could use the ShowInEditForm and the ShowInNewForm but check for the NULL. Is it is different than NULL, use this value. Else, try your condition check.

share|improve this answer
add comment

There is a more, um, DETAILED answer here, but it seems top-heavy to me:

http://sandeepnakarmi.com.np/2010/06/sharepoint-lists-editable-fields/

I had this same problem today and found a more elegant answer, although Attachments seems to be a one-off fix. You also need to keep in mind that you can hide user-editable fields yourself, and they will appear as Hidden = true. For my case, I want to list all user-serviceable fields, including ones I had hidden from the user.

This method returns true if the field given is a user-editable field:

private bool IsValidField(SPField objField)
{
  return (!objField.ReadOnlyField &&
    objField.CanToggleHidden &&
    objField.Type != SPFieldType.Attachments);
}

OK, just let me say that the code block formatting feature in this forum kicks ass. I love it.

P.S. I realize this thread is almost a year old, so I presume the OP has found his answer or, as is usually the case, a work-around. I try to provide an answer to old threads when it relates to my current dilemna, as I figure someone else is going to search for the same problem as me, and it is better to have an answer in an old thread than none at all.

share|improve this answer
add comment

Your Answer

 
discard

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.